CompTIA Network+ Certification Chapter 7 PDF
Document Details
Uploaded by FoolproofTopaz
Jefferson
Tags
Summary
This chapter introduces the basics of TCP/IP networking. It discusses the TCP/IP protocol suite, how it works, and the historical context. It also shares ideas about different types of IP addresses, specifically IPv4 and IPv6. Moreover, it explains important concepts such as subnetting, static and dynamic IP addresses and more.
Full Transcript
All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 TCP/IP Basics CHAPTER...
All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 TCP/IP Basics CHAPTER 6 The CompTIA Network+ certification exam expects you to know how to 1.1 Compare and contrast the Open Systems Interconnection (OSI) model layers and encapsulation concepts 1.2 Explain the characteristics of network topologies and types 1.4 Given a scenario, configure a subnet and use appropriate IP addressing schemes 1.5 Explain common ports and protocols, their application, and encrypted alternatives 1.6 Explain the use and purpose of network services 2.3 Given a scenario, configure and deploy common Ethernet switching features 4.2 Compare and contrast common types of attacks 5.5 Given a scenario, troubleshoot general networking issues To achieve these goals, you must be able to Describe how the TCP/IP protocol suite works Explain CIDR and subnetting Describe the functions of static and dynamic IP addresses The mythical MHTechEd network (remember that from Chapter 1?) provided an over- view of how networks work. The foundation of every physical network is hardware: wires, network interface cards, and other stand-alone network devices that move data from one computer to another. This hardware corresponds to OSI Layers 1 and 2—the Physical and Data Link layers (though some devices may also perform higher-layer func- tions). The higher layers of the model—from Network up to Application—work with this hardware to make network magic. Chapters 2 through 5 provided details of the hardware at the Physical and Data Link layers of the OSI model. You learned about the network protocols, such as Ethernet, which standardize networking so that data sent by one NIC can be read correctly by another NIC. 171 06-ch06.indd 171 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 CompTIA Network+ Certification All-in-One Exam Guide 172 This chapter begins a fun journey into the software side of networking. You’ll learn the details about the IP addressing scheme that enables computers on one network to com- municate with each other and with computers on other networks. You’ll get the full story of how TCP/IP networks divide into smaller units—subnets—to make management of a large TCP/IP network easier. And you won’t just get it from a conceptual standpoint. This chapter provides the details you’ve undoubtedly been craving—it teaches you how to set up a network properly. The chapter finishes with an in-depth discussion on imple- menting IP addresses. Historical/Conceptual The early days of networking, roughly the 1980s, exposed a problem in the way the software developers created the programs that powered networks at the time. Unlike the hardware organizations that worked together to make solid standards, the differ- ent organizations developing network software worked separately, secretly, and competi- tively. The four major players—Microsoft, Apple, Novell, and UNIX developers such as AT&T—created network software solutions that were mostly incompatible and had very different answers to the question “What do we share on a network?” Microsoft, Apple, and Novell created networking software that for the most part did nothing more than share different computers’ folders and printers (and they all did this sharing differently). AT&T and the universities developing the UNIX operating system saw networks as a way to share terminals, send e-mail messages, and transfer files. As a result, everyone’s software had its own set of Rules of What a Network Should Do and How to Do It. These sets of rules—and the software written to follow these rules—were broken down into individual rules or languages called protocols. No single protocol could do everything a network needed to do, so companies lumped together all their neces- sary protocols under the term protocol suite. Novell called its protocol suite IPX/SPX; Microsoft’s was called NetBIOS/NetBEUI; Apple called its protocol suite AppleTalk; and the UNIX folks used this wacky protocol suite called TCP/IP. It took about 20 very confusing years, but eventually TCP/IP replaced every other protocol suite in all but the most rare and unique situations. To get ahead today, to get on the Internet, and to pass the CompTIA Network+ exam, you only need to worry about TCP/IP. Microsoft, Apple, and Linux developers no longer actively support anything but TCP/IP. You live in a one-protocol-suite world, the old stuff is forgotten, and you kids don’t know how good you’ve got it! Test Specific The TCP/IP Protocol Suite If you recall from Chapter 1, the first two layers of the OSI seven-layer model deal with physical connectivity—wires and such—and protocols that interact with the physical. These are Layer 1, Physical, and Layer 2, Data Link. The TCP/IP protocol suite operates at Layers 3–7 of the OSI seven-layer model. This chapter explores Layer 3, Network, for 06-ch06.indd 172 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 Chapter 6: TCP/IP Basics 173 the most part, though I’ll remind you about Layer 4, Transport protocols, and Layer 7, Application protocols, before the deep dive into the Network layer. Network Layer Protocols Internet Protocol (IP) works at the Network layer, where it takes data chunks from the Transport layer (which become the packet’s payload ), adds addressing, and creates the final IP packet. IP then hands the IP packet to the Data Link layer for encapsulation into a frame. Let’s look at the addressing in more depth. I think it’s safe to assume that most folks have seen IP addresses before. Here’s a typical example: 192.168.1.115 This type of address—four values ranging from 0 to 255, separated by three periods—is known officially as an Internet Protocol version 4 (IPv4) address. This chapter introduces you to IPv4 addresses. You should understand the correct name for this older type of address because the world is in a slow transition to a newer, longer type of IP address called IPv6. Here’s an example of an IPv6 address: 2001:0:4137:9e76:43e:2599:3f57:fe9a IPv4 and IPv6 aren’t the only TCP/IP protocols that work at the Network layer. Inter- net Control Message Protocol (ICMP), for example, plays a role in IP error reporting and diagnostics. TCP/IP users rarely start a program that uses ICMP (or its IPv6 counter- part, ICMPv6). For the most part, software automatically uses ICMP as needed without direct user action. There are exceptions to every rule: the ping utility, a popular network diagnostic tool, directly uses ICMP. You can use ping to answer a question like, “can my computer communicate with any device at the IP address 192.168.1.15?” When thinking about the Network layer, remember the following three protocols: IPv4 (normally referred to as simply “IP”) IPv6 ICMP Figure 6-1 shows a highly simplified Internet Protocol (IP) header. Figure 6-1 Simplified IPv4 header NOTE Chapter 12 goes into IPv6 in detail. 06-ch06.indd 173 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 CompTIA Network+ Certification All-in-One Exam Guide 174 The full IPv4 packet header has 14 different fields. As discussed in Chapter 1, the des- tination and source IP address fields are critical for getting packets to their destination. Dissecting the entire set of fields isn’t important this early in the discussion, but here are a few to whet your appetite: Version The version (Ver) field defines the IP address type: 4, for IPv4. If you’re thinking, “Hey, Mike, what about 6?” I’ve got a surprise for you. The IPv6 packet header also starts with a version field (which is “6”), but the formats differ after that field. We’ll look at the IPv6 header format separately in Chapter 12. Total Length The total size of the IP packet in octets. This includes the IP header and its payload. This field is 16 bits, which limits the packet size to 65 KB. Time to Live (TTL) Implementations of routers on the Internet are not perfect and engineers sometimes create loops. The TTL field prevents an IP packet from indefinitely spinning through the Internet by using a counter that decrements by one every time a packet goes through a router. This number cannot start higher than 255; many operating systems start at 128. Protocol In most cases, the protocol field is either TCP or UDP and identifies what’s encapsulated inside the packet. See the next section for more information. Transport Layer Protocols When moving data from one system to another, the TCP/IP protocol suite needs to know if the communication is connection-oriented or connectionless. If the data moving between two systems must get there in good order, a connection-oriented application is the safe bet. If it’s not a big deal for data to miss a bit or two, then connectionless is the way to go. The connection-oriented protocol used with TCP/IP is called the Transmis- sion Control Protocol (TCP). The connectionless one is called the User Datagram Protocol (UDP). Let me be clear: you don’t choose TCP or UDP. The people who develop an applica- tion decide which protocol to use. The people who build Discord or Twitch or Firefox or Zoom pick (and sometimes even design) one or more protocols that they think will meet their application’s needs. These protocols are, in turn, designed to use TCP, UDP, or both. TCP Most TCP/IP applications use TCP—that’s why the protocol suite is called “TCP/IP” and not “UDP/IP.” TCP gets an application’s data from one machine to another reliably and completely. As a result, TCP comes with communication rules that require both the sending and receiving machines to acknowledge the other’s presence and readiness to send and receive data. This process is referred to as the TCP three-way handshake of 06-ch06.indd 174 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 Chapter 6: TCP/IP Basics 175 SYN, SYN-ACK, and ACK (Figure 6-2). TCP also chops up data into segments, gives the segments a sequence number, and then verifies that all sent segments were received. If a segment goes missing, the receiving system must request the missing segments. Figure 6-2 TCP three-way handshake in action Figure 6-3 shows a simplified TCP header. Notice the source port and the destination port. Port numbers, which range from 1 to 65,535, are used by systems to determine what application needs the received data. Each application is assigned a specific port number on which to listen/send. Web servers use port 80 (HTTP) or 443 (HTTPS), for example, whereas port 143 is used to receive e-mail messages from e-mail servers (IMAP4). Figure 6-3 TCP header EXAM TIP You might be required to select the fully spelled-out version of “TCP header” on the CompTIA Network+ exam, as in Transmission Control Protocol (TCP) header. The client uses the source port number to remember which client application requested the data. The rest of this book dives much deeper into ports. For now, know that the TCP or UDP header inside an IP packet stores these values. Ports aren’t the only items of interest in the TCP header. The header also contains these fields: Sequence number and acknowledgment number These numbers enable the sending and receiving computers to keep track of the various pieces of data flowing back and forth. Flags These individual bits give both sides detailed information about the state of the connection. (These appear in the CompTIA Network+ objectives as TCP flags.) Checksum The recipient can use the checksum to check the TCP header for errors such as bits flipped or lost during transmission. 06-ch06.indd 175 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 CompTIA Network+ Certification All-in-One Exam Guide 176 UDP UDP is the “fire and forget” missile of the TCP/IP protocol suite. As you can see in Figure 6-4, a UDP datagram header doesn’t possess any of the extra fields TCP segment headers carry to make sure the data is received intact. UDP works best when you have a lot of data that doesn’t need to be perfect or when the systems are so close to each other that the chances of a problem occurring are too small to bother worrying about. A few dropped frames on a Voice over IP call, for example, won’t make much difference in the communication between two people. So, there’s a good reason to use UDP: it’s smoking fast compared to TCP. Two of the most important networking protocols, Domain Name System (DNS) and Dynamic Host Configuration Protocol (DHCP), use UDP. Figure 6-4 UDP header EXAM TIP You might be required to select the fully spelled-out version of “UDP header” on the CompTIA Network+ exam, as in User Datagram Protocol (UDP) header. NOTE You saw this back in Chapter 1, but I’ll mention it again here. Data gets chopped up into chunks at the Transport layer when using TCP. The chunks are called segments with TCP. UDP datagrams don’t get chopped up at the Transport layer; they just get a header. Application Layer Protocols TCP/IP applications use TCP/IP protocols to move data back and forth between clients and servers. Because every application has different needs, I can’t show you a generic application header. Instead, we’ll look at a sample header from a pillar of the World Wide Web—the Hypertext Transfer Protocol (HTTP). Web servers and Web browsers use HTTP (or, more accurately, HTTPS, a secure version of HTTP wrapped in encryption—we’ll take a closer look at it in Chapter 10) to communicate. Figure 6-5 shows a sample header for HTTP. Specifically, this header is a response from a Web server containing a resource the client previously requested. This header—it’s just text—begins with “HTTP/1.1,” which indicates the version of the HTTP protocol in use. The “200 OK” indicates a successful request. The first blank line separates the end of the header from the beginning of the response body (which contains the requested Web page). 06-ch06.indd 176 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 Chapter 6: TCP/IP Basics 177 Figure 6-5 HTTP header NOTE I’m simplifying the call and response interaction between a Web server and a Web client. The explanation here is only part of the process of accessing a Web page. Super! Now that you’re comfortable with how the TCP/IP protocols fit into clear points on the OSI seven-layer model, let’s head back to the Network layer and explore IP addressing. IP and Ethernet TCP/IP supports simple networks and complex networks. You can use the protocol suite and a switch to connect a handful of computers in the same place into a local area net- work (LAN). TCP/IP also enables you to interconnect multiple LANs into a wide area network (WAN). Let’s start by examining how IP addressing works in a simple network, a LAN. 06-ch06.indd 177 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 CompTIA Network+ Certification All-in-One Exam Guide 178 NOTE We say LAN so often in networking that you might assume it has a crystal-clear definition, but there’s a bit of art in it. A LAN generally (but not always) belongs to one household or organization. A LAN covers a limited place—but that can mean anything from two devices in an apartment up to thousands of devices on a multi-building school or business campus. A WAN in a basic sense means a collection of interconnected LANs. Most authors also add a geographical context to the term, such as “spread out over a large area.” At the LAN level, every host runs TCP/IP software over Ethernet hardware, creating a situation where every host has two addresses: an IP address and an Ethernet MAC address (Figure 6-6). While at first this seems redundant, it’s the power behind TCP/IP’s ability to support both LANs and WANs. But again, we’re only talking about LANs at this point. Figure 6-6 Two addresses Imagine a situation where one computer, Computer A, wants to send an IP packet to another computer, Computer B, on the LAN. To send an IP packet to another computer, the sending computer (Computer A) must insert the IP packet into an Ethernet frame, as shown in Figure 6-7. Figure 6-7 Encapsulation of an IP packet inside an Ethernet frame 06-ch06.indd 178 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 Chapter 6: TCP/IP Basics 179 Note that the IP packet is completely encapsulated inside the Ethernet frame. Also note that the Ethernet header—the initial portion of the frame—has both a destination MAC address and a source MAC address, while the IP packet encapsulated in the Ether- net frame has both a source IP address and a destination IP address. This encapsulation idea works great, but there’s a problem: Computer A knows Computer B’s IP address, but how does Computer A know the MAC address of Computer B? (See Figure 6-8.) Figure 6-8 What is its MAC address? NOTE The Ethernet header includes the destination and source MAC addresses, plus the Type field. The latter can indicate the size of the payload in octets or the protocol of the encapsulated payload. To get Computer B’s MAC address, Computer A sends a special query called an ARP request to MAC address FF-FF-FF-FF-FF-FF, the universal MAC address for broadcast (Figure 6-9). The switch forwards the broadcast to every connected node. Figure 6-9 Sending an ARP request 06-ch06.indd 179 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 CompTIA Network+ Certification All-in-One Exam Guide 180 EXAM TIP The process and protocol used in resolving an IP address to an Ethernet MAC address is called Address Resolution Protocol (ARP). Computer B responds to the ARP request by sending Computer A an ARP reply (Figure 6-10) through the switch. Once Computer A has Computer B’s MAC address, it starts sending unicast Ethernet frames to Computer B through the switch. Figure 6-10 Computer B responds. Try This! ARP in Windows To show a Windows system’s current ARP cache, open a command line and type arp –a You should see results like this: Interface: 192.168.4.71 --- 0x4 Internet Address Physical Address Type 192.168.4.76 00-1d-e0-78-9c-d5 dynamic 192.168.4.81 00-1b-77-3f-85-b4 dynamic Now delete one of the entries in the ARP table with this command: arp –d [ip address from the previous results] Run the arp –a command again. The line for the address you specified should be gone. Now ping the address you deleted and check the ARP table again. Did the deleted address return? IP addresses provide several benefits that MAC addresses alone cannot offer. First, IP addresses are not a fixed part of the NIC. They can be changed to suit the needs of the network designer. Second, IP addresses group together sets of computers into logical 06-ch06.indd 180 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 Chapter 6: TCP/IP Basics 181 networks, so you can, for example, distinguish one LAN from another. Finally, because TCP/IP network equipment understands the IP addressing scheme, computers can com- municate with each other across all of the LANs that make up a WAN. Let’s go into more detail on IP addresses. IP Addresses The most common type of IP address (officially called IPv4, but usually simplified to just “IP”) consists of a 32-bit value. Here’s an example of an IP address: 11000000101010000000010000000010 Whoa! IP addresses are just strings of 32 binary digits? Yes, they are, but to make IP addresses easier for humans to use, the 32-bit binary value is broken down into four groups of eight, separated by periods, or dots, like this: 11000000.10101000.00000100.00000010 Each of these 8-bit values is, in turn, converted into a decimal number between 0 and 255. If you took every possible combination of eight binary values and placed them in a spreadsheet, it would look something like the list in the left column. The right column shows the same list with a decimal value assigned to each. 00000000 00000000 = 0 00000001 00000001 = 1 00000010 00000010 = 2 00000011 00000011 = 3 00000100 00000100 = 4 00000101 00000101 = 5 00000110 00000110 = 6 00000111 00000111 = 7 00001000 00001000 = 8 (skip a bunch in the middle) (skip a bunch in the middle) 11111000 11111000 = 248 11111001 11111001 = 249 11111010 11111010 = 250 11111011 11111011 = 251 11111100 11111100 = 252 11111101 11111101 = 253 11111110 11111110 = 254 11111111 11111111 = 255 Converted, the original value of 11000000.10101000.00000100.00000010 is dis- played as 192.168.4.2 in IPv4’s dotted decimal notation. Note that dotted decimal is 06-ch06.indd 181 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 CompTIA Network+ Certification All-in-One Exam Guide 182 simply a shorthand way for people to discuss and configure the binary IP addresses computers use. People who work on TCP/IP networks must know how to convert dotted decimal to binary and back. You can convert easily using any operating system’s calculator. Every OS has a calculator (UNIX/Linux systems have about 100 different ones to choose from) that has a scientific or programmer mode like the ones shown in Figure 6-11. Figure 6-11 Windows (left) and macOS (right) calculators in Programmer mode SIM Check out two excellent Chapter 6 “Binary Calculator” sims over at https://totalsem.com/008. Watch the Show! and then practice on the Click! To convert from decimal to binary, go to decimal view, enter the decimal value, and then switch to binary view to get the result. To convert from binary to decimal, go to binary view, enter the binary value, and switch to decimal view to get the result. Figure 6-12 shows the result of Windows 10 Calculator converting the decimal value 42 into binary. Notice the result is 101010—the leading two zeroes do not appear. When you work with IP addresses, you must always have eight digits, so just add two more to the left to get 00101010. NOTE Using a calculator utility to convert to and from binary/decimal is a critical skill for a network tech. Later on you’ll do this again, but by hand! 06-ch06.indd 182 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 Chapter 6: TCP/IP Basics 183 Figure 6-12 Converting decimal to binary with Windows 10 Calculator Just as every MAC address must be unique on a network, every IP address must be unique as well. For logical addressing to work, no two computers on the same network may have the same IP address. In a small network running TCP/IP, every computer has both an IP address and a MAC address (Figure 6-13), as you know from earlier in the chapter. Figure 6-13 A small network with both IP and MAC addresses 06-ch06.indd 183 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 CompTIA Network+ Certification All-in-One Exam Guide 184 Every operating system comes with utilities to display a system’s IP address and MAC address. Figure 6-14 shows a macOS system’s Network utility with TCP/IP information displayed. Note the IP address (192.168.50.157). Figure 6-15 shows the Hardware infor- mation in the same utility, which shows the MAC address. Figure 6-14 macOS Network utility 06-ch06.indd 184 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 Chapter 6: TCP/IP Basics 185 Figure 6-15 macOS Network utility displaying a MAC address Every operating system also has a command-line utility that gives you this informa- tion. In Windows, for example, the ipconfig command can display the IP and MAC addresses. (The latter requires the /all switch.) Run ipconfig /all to see the results shown in Figure 6-16. 06-ch06.indd 185 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 CompTIA Network+ Certification All-in-One Exam Guide 186 Figure 6-16 Result of running ipconfig /all in Windows In macOS, you can run the very similar ifconfig command. Figure 6-17, for example, shows the result of running ifconfig (“en0” is the NIC) from the terminal. 06-ch06.indd 186 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 Chapter 6: TCP/IP Basics 187 Figure 6-17 Result of running ifconfig in macOS On Linux systems, you can run either the newer ip address (see Figure 6-18) or the older ifconfig from a terminal to display a system’s IP and MAC addresses. (A lot of distros have removed net-tools, so ifconfig won’t be an option.) Note that most distros enable you to shorten the command switch and will fill in the word “address.” So ip addr or even ip a will work. 06-ch06.indd 187 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 CompTIA Network+ Certification All-in-One Exam Guide 188 Figure 6-18 Result of running ip address in Ubuntu EXAM TIP Make sure you know that ipconfig, ifconfig, and ip provide a tremendous amount of information regarding a system’s TCP/IP settings. IP Addresses in Action Now that you understand that an IP address is nothing more than a string of 32 ones and zeroes, it’s time to (finally) see how IP addressing supports WANs. It’s important to keep in mind that the IP numbering system must support both WANs and the many LANs connected by the WANs. This can create problems in some circumstances, such as when a computer needs to send data both to computers in its own network and to computers in other networks at the same time. To make all this work, the IP numbering system must do three things: Create network IDs, a way to use IP addresses so that each LAN has its own identification. Interconnect the LANs using routers and give those routers some way to use the network ID to send packets to the right network. Use a subnet mask to give each computer on the network a way to recognize if a packet is for the LAN or for a computer on the WAN, so it knows how to handle the packet. Network IDs A WAN is nothing more than a group of two or more interconnected LANs. For a WAN to work, each LAN needs some form of unique identifier called a network ID. 06-ch06.indd 188 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 Chapter 6: TCP/IP Basics 189 To differentiate LANs from one another, each computer on a single LAN must share a very similar, but not identical, IP address. Some parts of the IP address will match all the others on the LAN. Figure 6-19 shows a LAN where all the computers share the first three numbers of the IP address, with only the last number being unique on each system. Figure 6-19 IP addresses for a LAN In this example, every computer has an IP address of 202.120.10.x, where the x value is unique for every host, but every host’s IP address starts with 202.120.10. That means the network ID is 202.120.10.0. The x part of the IP address is the host ID. Combine the network ID (after dropping the ending 0) with the host ID to get an individual system’s IP address. No individual computer can have an IP address that ends with 0 because that is reserved for network IDs. NOTE Two things to note here. First, the network ID and the host ID are combined to make a system’s IP address. Second, a host ID can end in 0— as long as it isn’t all zeroes—but we have to discuss subnetting before any of this will make sense. Read on! 06-ch06.indd 189 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 CompTIA Network+ Certification All-in-One Exam Guide 190 Interconnecting LANs To organize all those individual LANs into a larger network, every TCP/IP LAN that wants to connect to another TCP/IP LAN must have a router connection. There is no exception to this critical rule. A router, therefore, needs an IP address on every LAN that it interconnects (Figure 6-20), so it can correctly send (route) the packets to the correct LAN. Figure 6-20 LAN with router When you have a router that routes traffic out to other networks, both the router’s interface on a LAN and the router itself are called the default gateway. In a typical sce- nario configuring a client to access the network beyond the router, you use the IP address of the default gateway. The default gateway is in the same network ID as the host. The network administrator who sets up the router must make sure to configure the router’s LAN interface to have an address in the LAN’s network ID. By convention, most net- work administrators give the LAN-side NIC on the default gateway the lowest or highest host address in the network. Therefore, if a network ID is 22.33.4.x, the router might be configured to use the address 22.33.4.1 or 22.33.4.254. Routers use network IDs to determine network traffic. Figure 6-21 shows a diagram for a small, two-NIC router similar to the ones you see in many homes. Note that one port (202.120.10.1) connects to the LAN and the other port connects to the Internet service provider’s network (14.23.54.223). Built into this router is a routing table: the actual instructions that tell the router what to do with incoming packets and where to send them. 06-ch06.indd 190 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 Chapter 6: TCP/IP Basics 191 Figure 6-21 Router diagram Now let’s add in the LAN and the Internet (Figure 6-22). When discussing networks in terms of network IDs (especially with illustrations in books) the common practice is to draw a circle around an illustrated network. Here, you should concentrate on the IDs—not the specifics of the networks. Figure 6-22 LAN, router, and the Internet NOTE Routing tables are covered in more detail in Chapter 7. Network IDs are very flexible, as long as no two interconnected networks share the same network ID. If you wished, you could change the network ID of the 202.120.10.0 network to 202.155.5.0, or 202.21.8.0, but only if you can guarantee that no other LAN on the WAN shares the same network ID. On the Internet, powerful governing bodies carefully allocate network IDs to ensure no two LANs share the same network ID. I’ll talk more about how this works later in the chapter. 06-ch06.indd 191 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 CompTIA Network+ Certification All-in-One Exam Guide 192 So far, you’ve only seen examples of network IDs where the last value is zero. This is common for small networks, but it creates a limitation. With a network ID of 202.120.10.0, for example, a network is limited to IP addresses from 202.120.10.1 to 202.120.10.254. (202.120.10.255 is a broadcast address used to talk to every computer on the LAN.) This provides only 254 IP addresses: enough for a small network, but many organizations need many more IP addresses. No worries! You can simply use a network ID with more zeroes, such as 170.45.0.0 (for a total of 65,534 hosts) or even 12.0.0.0 (for around 16.7 million hosts). Network IDs enable you to connect multiple LANs into a WAN. Routers then con- nect everything together, using routing tables to keep track of which packets go where. So that takes care of the second task: interconnecting the LANs using routers and giving those routers a way to send packets to the right network. Now that you know how IP addressing works with LANs and WANs, let’s turn to how IP enables each computer on a network to recognize if a packet is going to a computer on the LAN or to a computer on the WAN. The secret to this is something called the subnet mask. Subnet Mask Picture this scenario. Three friends sit at their computers—Computers A, B, and C— and want to communicate with each other. Figure 6-23 illustrates the situation. You can tell from the drawing that Computers A and B are in the same LAN, whereas Computer C is on a completely different LAN. The IP addressing scheme can handle this commu- nication, so let’s see how it works. Figure 6-23 The three amigos, separated by walls or miles The process to get a packet to a local computer is very different from the process to get a packet to a faraway computer. If one computer wants to send a packet to a local computer, it must send a broadcast to get the other computer’s MAC address. (It’s easy to 06-ch06.indd 192 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 Chapter 6: TCP/IP Basics 193 forget about the MAC address, but remember that Layer 2 requires the MAC address to get the packet to the other computer.) If the packet is for some computer on a faraway network, the sending computer must send the packet to the default gateway (Figure 6-24). Figure 6-24 Sending a packet to a remote location In the scenario illustrated in Figure 6-23, Computer A wants to send a packet to Computer B. Computer B is on the same LAN as Computer A, but that begs a ques- tion: How does Computer A know this? Every TCP/IP computer needs a tool to tell the sending computer whether the destination IP address is local or long distance. This tool is the subnet mask. A subnet mask is nothing more than a string of ones followed by some number of zeroes, always totaling exactly 32 bits, set on every TCP/IP host. Here’s an example of a typical subnet mask: 11111111111111111111111100000000 For the courtesy of the humans reading this (if any computers are reading this book, please call me—I’d love to meet you!), let’s convert this to dotted decimal. First, add some dots: 11111111.11111111.11111111.00000000 Then convert each octet into decimal (use a calculator): 255.255.255.0 When you line up an IP address with a corresponding subnet mask in binary, the portion of the IP address that aligns with the ones of the subnet mask is the network ID portion of the IP address. The portion that aligns with the zeroes is the host ID. With simple IP addresses, you can see this with dotted decimal, but you’ll want to see this in binary for a true understanding of how the computers work. 06-ch06.indd 193 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 CompTIA Network+ Certification All-in-One Exam Guide 194 TIP At this point, you should memorize that 0 = 00000000 and 255 = 11111111. You’ll find knowing this very helpful throughout the rest of the book. The IP address 192.168.5.23 has a subnet mask of 255.255.255.0. Convert both numbers to binary and then compare the full IP address to the ones and zeroes of the subnet mask: Dotted Decimal Binary IP address 192.168.5.23 11000000.10101000.00000101.00010111 Subnet mask 255.255.255.0 11111111.11111111.11111111.00000000 Network ID 192.168.5.0 11000000.10101000.00000101.x Host ID x.x.x.23 x.x.x.00010111 Before a computer sends out any data, it first compares its network ID to the des- tination’s network ID. If the network IDs match, then the sending computer knows the destination is local. If they do not match, the sending computer knows it’s a long- distance call. NOTE The explanation about comparing an IP address to a subnet mask simplifies the process, leaving out how the computer uses its routing table to accomplish the goal. We’ll get to routing and routing tables in Chapter 7. For now, stick with the concept of the node using the subnet mask to determine the network ID. Let’s head over to Computer A and see how the subnet mask works. Computer A’s IP address is 192.168.5.23. Convert that into binary: 11000000.10101000.00000101.00010111 Now drop the periods because they mean nothing to the computer: 11000000101010000000010100010111 Let’s say Computer A wants to send a packet to Computer B. Computer A’s subnet mask is 255.255.255.0. Computer B’s IP address is 192.168.5.45. Convert this address to binary: 11000000101010000000010100101101 Computer A compares its IP address to Computer B’s IP address using the subnet mask, as shown in Figure 6-25. For clarity, I’ve added a line to show you where the ones end and the zeroes begin in the subnet mask. Computers certainly don’t need the line! 06-ch06.indd 194 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 Chapter 6: TCP/IP Basics 195 Figure 6-25 Comparing addresses Aha! Computer A’s and Computer B’s network IDs match! It’s a local call. Knowing this, Computer A can now send out an ARP request, which is a broadcast, to determine Computer B’s MAC address. Address Resolution Protocol (ARP) is how a TCP/IP net- work figures out the MAC address based on the destination IP address, as you’ll recall from earlier in the chapter. Figure 6-26 Comparing addresses again 06-ch06.indd 195 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 CompTIA Network+ Certification All-in-One Exam Guide 196 But what happens when Computer A wants to send a packet to Computer C? First, Computer A compares Computer C’s IP address to its own using the subnet mask (Figure 6-26). It sees that the IP addresses do not match in the all-ones part of the subnet mask—meaning the network IDs don’t match; therefore, this is a long-distance call. Whenever a computer wants to send to an IP address on another LAN, it knows to send the packet to the default gateway. It still sends out an ARP broadcast, but this time it’s to learn the MAC address for the default gateway (Figure 6-27). Once Computer A gets the default gateway’s MAC address, it then begins to send packets. Figure 6-27 Sending an ARP request to the gateway Subnet masks are represented in dotted decimal like IP addresses—just remember that both are really 32-bit binary numbers. All the following (shown in both binary and dot- ted decimal formats) can be subnet masks: 11111111111111111111111100000000 = 255.255.255.0 11111111111111110000000000000000 = 255.255.0.0 11111111000000000000000000000000 = 255.0.0.0 Most network folks represent subnet masks using shorthand called CIDR notation: a / character followed by a number equal to the number of ones in the subnet mask (CIDR is covered in more depth a bit later in the chapter). Here are a few examples: 11111111111111111111111100000000 = /24 (24 ones) 11111111111111110000000000000000 = /16 (16 ones) 11111111000000000000000000000000 = /8 (8 ones) An IP address followed by the / and number tells you the IP address and the subnet mask in one statement. For example, 201.23.45.123/24 is an IP address of 201.23.45.123 with a subnet mask of 255.255.255.0. Similarly, 184.222.4.36/16 is an IP address of 184.222.4.36 with a subnet mask of 255.255.0.0. 06-ch06.indd 196 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 Chapter 6: TCP/IP Basics 197 NOTE By definition, all computers on the same network have the same subnet mask and network ID. Class IDs The Internet is by far the biggest and the most complex TCP/IP internetwork. Numbering over half a billion computers already a decade ago, it has grown so quickly that now it’s nearly impossible to find an accurate number. One challenge for the Internet is to make sure no two devices share the same public IP address. To support the dispersion of IP addresses, an organization called the Internet Assigned Numbers Authority (IANA) was formed to track and disperse IP addresses to those who need them. Initially handled by a single person (Jon Postel) until his death in 1998, IANA has grown dramatically and now oversees five Regional Internet Registries (RIRs) that parcel out IP addresses to ISPs and corporations. The RIR for North America is called the American Registry for Internet Numbers (ARIN). All end users get their IP addresses from their respective ISPs. IANA manages contiguous chunks called network blocks (or just blocks). Once upon a time, there was a “class” system for organizing and defining these blocks, which is outlined in the following table: First Decimal Value Addresses Hosts per Network ID Class A 1–126 1.0.0.0–126.255.255.255 16,777,216 Class B 128–191 128.0.0.0–191.255.255.255 65,534 Class C 192–223 192.0.0.0–223.255.255.255 254 Class D 224–239 224.0.0.0–239.255.255.255 Multicast Class E 240–255 240.0.0.0–255.255.255.255 Experimental NOTE This class system has long since gone the way of the dodo, but techs do still use these classes as shorthand for the private address ranges that organizations and households worldwide use for their internal networks. We’ll take a closer look at these private address ranges in the “Special IP Addresses” section at the end of the chapter. A typical Class A network block, for example, had a network ID starting between 1 and 126; hosts on that network had only the first octet in common, with any numbers for the other three octets. Having three octets to use for hosts means an enormous num- ber of possible hosts, over 16 million different combinations. The corresponding subnet mask for a Class A network block would be 255.0.0.0, leaving 24 bits for host IDs. 06-ch06.indd 197 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 CompTIA Network+ Certification All-in-One Exam Guide 198 EXAM TIP CompTIA and many techs use the term classful to describe the traditional class blocks. Thus, you’ll see classful A, B, C, D, and E addressing on the exam. Keep reading and this will make sense. Do you remember binary math? 224 = 16,777,216. Because the host can’t use all zeroes or all ones (those are reserved for the network ID and broadcast address, respectively), you should subtract two from the final number to get the available host IDs (both in this example, and in the ones below). NOTE The Internet Corporation for Assigned Names and Numbers (ICANN) indirectly manages IANA through an affiliate organization, Public Technical Identifiers (PTI). PTI was formed to perform IANA’s technical work; ICANN is more focused on policy. A Class B network block, which would correspond to a subnet mask of 255.255.0.0, used the first two octets to define the network ID. This left two octets to define host IDs, meaning each Class B network ID could have up to 216 – 2 = 65,534 different hosts. A Class C network block used the first three octets to define only the network ID. All hosts in network 192.168.35.0, for example, would have all three first numbers in com- mon. Only the last octet defined the host IDs, leaving just 28 – 2 = 254 possible unique addresses. The subnet mask corresponding to a Class C block is 255.255.255.0. Multicast class blocks are used for one-to-many communication (though we don’t really refer to them as classes anymore), such as in streaming video conferencing. There are four ways to send a packet: a broadcast, which is where every computer on the LAN hears the message; a unicast, where one computer sends a message directly to another; an anycast, where multiple computers share a single address and routers direct messages to the closest computer; and a multicast, where a single computer sends a message to a group of interested computers. Routers use multicast to talk to each other. Experimental addresses are reserved and never used except for occasional experimental reasons. These were originally called Reserved addresses. EXAM TIP Make sure you memorize the IP class blocks! You should be able to look at any IP address and know its class block. Here’s a trick to help: The first binary octet of a Class A address always begins with a 0 (0xxxxxxx); for Class B, it begins with a 10 (10xxxxxx); for Class C, with 110 (110xxxxx); for Class D, with 1110 (1110xxxx); and for Class E, it begins with 1111 (1111xxxx). 06-ch06.indd 198 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 Chapter 6: TCP/IP Basics 199 IP class blocks worked well for the first few years of the Internet but quickly ran into trouble because they didn’t quite fit for everyone. Early on, IANA gave away IP network blocks rather generously, perhaps too generously. Over time, unallocated IP addresses became scarce. Additionally, the IP class block concept didn’t scale well. If an organiza- tion needed 2000 IP addresses, for example, it either had to take a single Class B network block (wasting 63,000 addresses) or eight Class C blocks. As a result, a new method of generating blocks of IP addresses, called Classless Inter-Domain Routing (CIDR), was developed. CIDR and Subnetting The foundation of CIDR is a concept called subnetting: taking a single class of IP addresses and chopping it up into multiple smaller groups called subnets. Once upon a time, subnetting was just One Weird Trick organizations used to break up and organize their networks. CIDR makes it possible to extend this subnetting approach to the Inter- net as a whole. RIRs and ISPs play an important role in taking blocks of IP addresses, breaking them up into multiple subnets, and assigning those subnets to smaller orga- nizations. Subnetting and CIDR have been around for quite a long time now and are a critical part of all but the smallest TCP/IP networks. Let’s first discuss subnetting and then visit CIDR. Subnetting Subnetting enables a much more efficient use of IP addresses compared to class blocks. It also enables you to separate a network for security (separating a bank of publicly acces- sible computers from your more private computers) and for bandwidth control (separat- ing a heavily used LAN from one that’s not so heavily used). EXAM TIP You need to know how to subnet to pass the CompTIA Network+ exam. The cornerstone to subnetting lies in the subnet mask. You take an existing /8, /16, or /24 subnet and extend the subnet mask by replacing zeroes with ones. For example, let’s say you have a café with public Wi-Fi and two computers in the back office for accounting and monitoring the shop’s security cameras (Figure 6-28). Your network ID is 192.168.4.0/24. You want to prevent people who are using the public systems from accessing your private machines, so you decide to set up two physically separate LANs—one for the guests, and one for your own systems—and then assign a subnet to each LAN. 06-ch06.indd 199 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 CompTIA Network+ Certification All-in-One Exam Guide 200 Figure 6-28 Layout of the network You need to keep two things in mind about subnetting. First, start with the given subnet mask and move it to the right until you have the number of subnets you need. Second, forget the dots. They no longer define the subnets. Never try to subnet without first converting to binary. Too many techs are what I call “victims of the dots.” They are so used to working only with class blocks that they forget there’s more to subnets than just /8, /16, and /24 networks. There is no reason network IDs must end on the dots. The computers, at least, think it’s perfectly fine to have sub- nets that end at points between the periods, such as /26, /27, or even /22. The trick here is to stop thinking about network IDs and subnet masks just in their dotted decimal format and instead return to thinking of them as binary numbers. NOTE Classful subnets were always /8, /16, or /24. 06-ch06.indd 200 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 Chapter 6: TCP/IP Basics 201 Let’s begin subnetting the café’s network of 192.168.4.0/24. Start by changing a zero to a one on the subnet mask so the /24 becomes a /25 subnet: 11111111111111111111111110000000 Calculating Hosts Before going even one step further, you need to answer this question: On a /24 network, how many hosts can you have? If you used dotted decimal notation, you might answer as follows: 192.168.4.1 to 192.168.4.254 = 254 hosts But do this from the binary instead. In a /24 network, you have eight zeroes that can be the host ID: 00000001 to 11111110 = 254 There’s a simple piece of math here: 2x – 2, where x represents the number of zeroes in the subnet mask. Subtract two for the network ID and broadcast address, just as when calculating the number of hosts in classful addressing. 28 – 2 = 254 If you remember this simple formula, you can always determine the number of hosts for a given subnet. This is critical! Memorize this! EXAM TIP Use this formula to know precisely the number of hosts for a given subnet: 2x − 2, where x = number of zeroes in the subnet mask. If you have a /16 subnet mask on your network, what is the maximum number of hosts you can have on that network? 1. Because a subnet mask always has 32 digits, a /16 subnet means you have 16 zeroes left after the 16 ones. 2. 216 – 2 = 65,534 total hosts. If you have a /26 subnet mask on your network, what is the maximum number of hosts you can have on that network? 1. Because a subnet mask always has 32 digits, a /26 subnet means you have 6 zeroes left after the 26 ones. 2. 26 – 2 = 62 total hosts. Excellent! Knowing how to determine the number of hosts for a subnet mask will help you tremendously, as you’ll see in a moment. 06-ch06.indd 201 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 CompTIA Network+ Certification All-in-One Exam Guide 202 Making a Subnet Let’s now make a subnet. All subnetting begins with a single network ID. In this sce- nario, you need to convert the 192.168.4.0/24 network ID for the café into three net- work IDs: one for the public computers, one for the private computers, and one for the wireless clients. NOTE You cannot subnet without using binary! The primary tool for subnetting is the existing subnet mask. Write it out in binary. Place a line at the end of the ones, as shown in Figure 6-29. Figure 6-29 Step 1 in subnetting Now draw a second line one digit to the right, as shown in Figure 6-30. You’ve now separated the subnet mask into three areas that I call (from left to right) the default subnet mask (DSM), the network ID extension (NE), and the hosts (H). These are not industry terms, so you won’t see them on the CompTIA Network+ exam, but they’re a handy Mike Trick that makes the process of subnetting a lot easier. Figure 6-30 Organizing the subnet mask You now have a /25 subnet mask. At this point, most people first learning how to sub- net start to freak out. They’re challenged by the idea that a subnet mask of /25 isn’t going to fit into one of the three pretty subnets of 255.0.0.0, 255.255.0.0, or 255.255.255.0. They think, “That can’t be right! Subnet masks are made of only 255s and 0s.” 06-ch06.indd 202 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 Chapter 6: TCP/IP Basics 203 That’s not correct. A subnet mask is a string of ones followed by a string of zeroes. People only convert the masks into dotted decimal to enter them into computers. So, convert /25 into dotted decimal. First write out 25 ones, followed by 7 zeroes. (Remember, sub- net masks are always 32 binary digits long.) 11111111111111111111111110000000 Insert the periods in between every eight digits: 11111111.11111111.11111111.10000000 Then convert them to dotted decimal: 255.255.255.128 Get used to the idea of subnet masks that use more than 255s and 0s. Here are some examples of perfectly legitimate subnet masks. Try converting these to binary to see for yourself: 255.255.255.224 255.255.128.0 255.248.0.0 Calculating Subnets When you subnet a network ID, you need to follow the rules and conventions dictated by the good folks who developed TCP/IP to ensure that your new subnets can interact properly with each other and with larger networks. All you need to remember for subnet- ting is this: start with a beginning subnet mask and extend the subnet extension until you have the number of subnets you need. The formula for determining how many subnets you create is 2y, where y is the number of bits you add to the subnet mask. Let’s practice this a few times. Figure 6-31 shows a starting subnet of 255.255.255.0. If you move the network ID extension over one, it’s only a single digit, 21. Figure 6-31 Initial subnetting 06-ch06.indd 203 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 CompTIA Network+ Certification All-in-One Exam Guide 204 That single digit is only a zero or a one, which gives you two subnets. You have only one problem—the café needs three subnets, not just two! So, let’s take /24 and subnet it down to /26. Extending the network ID by two digits creates four new net- work IDs, 22 = 4. To see each of these network IDs, first convert the original network ID—192.168.4.0—into binary. Then add the four different network ID extensions to the end, as shown in Figure 6-32. Figure 6-32 Creating the new network IDs Figure 6-33 shows all the IP addresses for each of the four new network IDs. Figure 6-33 New network ID address ranges 06-ch06.indd 204 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 Chapter 6: TCP/IP Basics 205 Now convert these four network IDs back to dotted decimal: Network ID Host Range Broadcast Address 192.168.4.0/26 (192.168.4.1–192.168.4.62) 192.168.4.63 192.168.4.64/26 (192.168.4.65–192.168.4.126) 192.168.4.127 192.168.4.128/26 (192.168.4.129–192.168.4.190) 192.168.4.191 192.168.4.192/26 (192.168.4.193–192.168.4.254) 192.168.4.255 Congratulations! You’ve just taken a single network ID, 192.168.4.0/24, and sub- netted it into four new network IDs! Figure 6-34 shows how you can use these new network IDs in a network. Figure 6-34 Three networks using the new network IDs You may notice that the café only needs three subnets, but you created four—you’re wasting one. Because subnets are created by powers of two, you will often create more subnets than you need—welcome to subnetting. NOTE If wasting subnets seems contrary to the goal of efficient use, keep in mind that subnetting has two goals: efficiency and making multiple network IDs from a single network ID. This example is geared more toward the latter goal. 06-ch06.indd 205 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 CompTIA Network+ Certification All-in-One Exam Guide 206 For a little more subnetting practice, let’s create eight subnets on a /27 network. First, move the NE over three digits (Figure 6-35). Figure 6-35 Moving the network ID extension three digits To help you visualize the address range, I’ll calculate the first two subnets—using 000 and 001 (Figure 6-36). Please do the other six for practice. Figure 6-36 Two of the eight network ID address ranges Note that in this case you only get 25 – 2 = 30 hosts per network ID! These better be small networks! Converting these to dotted decimal, you get the following: 192.168.4.0/27 (192.168.4.1–192.168.4.30) 192.168.4.32/27 (192.168.4.33–192.168.4.62) 192.168.4.64/27 (192.168.4.65–192.168.4.94) 192.168.4.96/27 (192.168.4.97–192.168.4.126) 192.168.4.128/27 (192.168.4.129–192.168.4.158) 192.168.4.160/27 (192.168.4.161–192.168.4.190) 192.168.4.192/27 (192.168.4.193–192.168.4.222) 192.168.4.224/27 (192.168.4.225–192.168.4.254) 06-ch06.indd 206 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 Chapter 6: TCP/IP Basics 207 These two examples began with a Class C address. However, you can begin with any starting network ID. Nothing changes about the process you just learned. EXAM TIP CompTIA and many techs refer to a CIDR address as a classless address, meaning the subnet used does not conform to the big three on the classful side: A, B, or C. When you see that term on the exam, you’ll know you should look for subnetting. The examples used in this introduction to subnetting took a single network ID and chopped it into identically sized subnets. The simplest subnetting example, in other words, created four /26 subnets from one /24 network ID. You can vary the size of the subnets created, however, with classless variable-length subnet masking (VLSM). ISPs might do this to accommodate different customer needs, taking a single network ID and handing out custom subnets. John’s tiny company might get a /30 subnet; Jennie’s larger company might get a /26 subnet to accommodate many more users. NOTE Assuming you could still order real, unique, ready-for-the-Internet IP addresses from your local ISP (you can’t), you’d invariably get a classless set of IP addresses. More importantly, when you work with clients, you need to be able to explain why their subnet mask is 255.255.255.192, when all the books they read tell them it should be 255.255.255.0! See Chapter 12 for the scoop on IPv6, the addressing scheme gradually replacing IPv4. Manual Dotted Decimal to Binary Conversion The best way to convert from dotted decimal to binary and back is to use a calculator. It’s easy, fast, and accurate. There’s always a chance, however, that you may find yourself in a situation where you need to convert without a calculator. Fortunately, manual conver- sion, although a bit tedious, is also easy. You just have to remember a single number: 128. Take a piece of paper and write the number 128 in the top-left corner. Now, what is half of 128? That’s right, 64. Write 64 next to 128. Now keep dividing the previous number in half until you get to the number 1. The result will look like this: 128 64 32 16 8 4 2 1 Notice that you have eight numbers. Each of these numbers corresponds to a position of one of the eight binary digits. To convert an 8-bit value to dotted decimal, just take the binary value and put the numbers under the corresponding eight digits. Wherever there’s a 1, add that decimal value. 06-ch06.indd 207 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 CompTIA Network+ Certification All-in-One Exam Guide 208 Let’s take the binary value 10010110 into decimal. Write down the numbers as shown, and then write the binary values underneath each corresponding decimal number: 128 64 32 16 8 4 2 1 1 0 0 1 0 1 1 0 Add the decimal values that have a 1 underneath: 128 + 16 + 4 + 2 = 150 Converting from decimal to binary is a bit more of a challenge. You still start with a line of decimal numbers starting with 128, but this time, you place the decimal value above. If the number you’re trying to convert is greater than or equal to the number underneath, subtract it and place a 1 underneath that value. If not, then place a 0 under it and move the number to the next position to the right. Let’s give this a try by convert- ing 221 to binary. Begin by placing 221 over the 128: 221 128 64 32 16 8 4 2 1 93 1 Now place the remainder, 93, over the 64: 93 128 64 32 16 8 4 2 1 29 1 1 Place the remainder, 29, over the 32. The number 29 is less than 32, so place a 0 under- neath the 32 and move 29 again, over the 16: 29 128 64 32 16 8 4 2 1 13 1 1 0 1 Then move to the 8: 13 128 64 32 16 8 4 2 1 5 1 1 0 1 1 Then the 4: 5 128 64 32 16 8 4 2 1 1 1 1 0 1 1 1 06-ch06.indd 208 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 Chapter 6: TCP/IP Basics 209 Then the 2. The number 1 is less than 2, so drop a 0 underneath and move to 1: 1 128 64 32 16 8 4 2 1 1 1 0 1 1 1 0 1 Finally, the 1; 1 is equal to 1, so put a 1 underneath and you’re done. The number 221 in decimal is equal to 11011101 in binary. EXAM TIP Make sure you can manually convert decimal to binary and binary to decimal. CIDR: Key Takeaways Subnetting is a competency everyone who’s serious about networking understands in detail—it’s a clear separation between those who know networks and those who do not. For the CompTIA Network+ exam, you need to be able to take any existing network ID and break it down into a given number of subnets. You need to know how many hosts the resulting network IDs possess. You need to be able to calculate the IP addresses and the new subnet masks for each of the new network IDs. You need to think of subnets in CIDR terms like /10, /22, /26, and so on. EXAM TIP Expect to see a question or two on the CompTIA Network+ exam that asks you to compare Classless Inter-Domain Routing (CIDR) notation (IPv4 vs. IPv6). The former should be familiar, with “notation” meaning the four octets and a /# for the subnet mask. See Chapter 12 for full coverage of IPv6. You’ve done well, my little Padawan. Subnetting takes a little getting used to. Go take a break. Take a walk. Play some World of Warcraft (I just can’t quit!), Fortnite, or maybe a few laps in Forza Horizon. After a good mental break, dive back into subnetting and prac- tice. Take any old network ID and practice making multiple subnets—lots of subnets! IP Address Assignment Whew! After all that subnetting, you’ve reached the point where it’s time to start using some IP addresses. That is, after all, the goal of going through all that pain. There are two ways to configure a host’s IP settings (for our purposes here, its IP address, subnet mask, and default gateway): either by typing in all the information (called static addressing) or by having a server program running on a system that automatically passes out all the IP information to systems as they boot up on or connect to a network (called dynamic addressing). Additionally, you must learn about several specialty IP addresses that have unique meanings in the IP world to make this all work. 06-ch06.indd 209 13/12/21 3:49 PM All-In-One / CompTIA Network+™ Certification All-in-One Exam Guide / Meyers & Jernigan / 905-6 / Chapter 6 CompTIA Network+ Certification All-in-One Exam Guide 210 EXAM TIP The CompTIA Network+ exam objectives use the terms static assignment and dynamic assignment to describe these static and dynamic addressing methods for setting device IP addresses. Static IP Addressing Static addressing means typing all the IP information into each of your hosts. But before you type in anything, you must answer two questions: What are you typing in and where do you type it? Let’s visualize a four-node network like the one shown in Figure 6-37. Figure 6-37 A small network To make this network function, each computer must have an IP address, a subnet mask, and a default gateway. First, decide what network ID to use. In the old days, your ISP gave you a block of IP addresses to use. Assume that’s still the method and you’ve been allocated a Class C network block for 197.156.4.0/24. The first rule of Internet addressing is…no one talks about Internet addressing. Actually, we can maul the Fight Club reference and instead say, “The first rule of Internet addressing is t