Author: Tom Large
Last Modified: 12-28-2K
Synopsis: This is a quick primer for TCP/IP subnetting. This is my first document to be thrown out to the wild, so please be gentle. If you have any comments or notice anything incorrect, I can be reached by sending email to tlarge@thelug.org -- I hope this helps with any questions you might have.
IP Addressing, a primer.
IP Addresses represent several things. The network your host lives on, and the address of your host are the two primary roles when you consider an IP Address. The easiest way to think of this is think of the street you live on as a network and your address as a host address. For example, if you live at 1234 Main Street, your network is Main Street and your host address is 1234. No two hosts can have the same address if they're on the same network. So, no two houses on Main Street could have address 1234. Also, no two networks can have the same identification. So, no other street (in your city at least) can be Main Street. Some more aspects of IP Addresses that most people don't think about when first learning IP Addressing, are: Subnet Masks, and Broadcast Addresses. These and other pieces will be covered in more detail below, but I thought these two at least needed to be mentioned here.
A few definitions:
Network Mask: The portion of an IP Address that defines the network identification. This is defined in one of two methods. In dotted decimal notation (ex: 255.255.255.0) and in a "slash" notation (ex: /24). This will be covered in the following pages.
Explanation: If your IP Address is 204.94.37.20/16, then your Network Mask is 11111111.11111111.00000000.00000000 (255.255.0.0).
Host Mask: The portion of an IP Address that defines the host identification.
Explanation: Given the same address as above, also part of a /16, then your Host mask is 00000000.00000000.11111111.11111111 (0.0.255.255). This mask is typically implied, given your network or subnet mask.
Subnet Mask: The portion of an IP Address that is borrowed from the Host Mask (if applicable). Using the analogy above (1234 Main Street), the easiest way to think of this would be to think in terms of blocks of houses. If each block is designated as a "100 block" (ex: 1xx, 2xx, 3xx...10xx, 11xx, 12xx), then we can take that idea of using the addresses to designate where on a network (Main Street) a particular house is. Large networks are often subnetted to make better use of IP Space, since there is a finite number of addresses available. Using the above example, we can break this down to networking terms. Your house's network address is Main Street, its subnet address is 12 and its host address is 34.
Explanation: Say you have an IP Address 208.176.17.171/28 - your network mask would be 255.255.255.0 and your subnet mask is .240, making your "NetMask" 11111111.11111111.11111111.11110000 (255.255.255.240). Notice 28 ones, and 4 zeros--hence the /28, since there's 32 bits (split into 4 octets by decimals) in an address: 32-4=28.
Network Address: An IP Address that defines a network.
Explanation: In the above /28 example, your network address would be 208.176.17.160 - here's why. 256 minus 240 is 16 (we use 256 for this to uncomplicate the fact that it really counts from zero to 255, not 1 to 256--either way you get the same answer). So each network range of 208.176.17.x contains 16 addresses. Now remembering that every network range must have a network address and a broadcast address, you only really get 14 *useable* addresses. The network address is the "zero" address and the broadcast address is the "255" address. So, given that the network address is the "zero" address, and our Host Address is .171, we can determine that we are in the .160-.175 range (by figuring the first range is .0-.15, second is .16-.31, etc.). So, our network address is 208.176.17.160. - tah-dah. Complicated as hell right now, easy once you get it.
Broadcast Address: The broadcast address is the address network broadcasts are sent to. It is the "255" (255 being the total of an 8 bit binary number of all 1's, given a subnet it would be a smaller number, depending on how many bits were given to it) of the network range. Using the /28 above, and using the same method to determine that our address range is .160-.175, we know that our broadcast address is .175 - because .175 is the LAST address in our range.
IP Address: The complete IP Address of any of the above. This address includes the Network Mask, Subnet Mask (if applicable), and Host Address. Or is either a network address or a broadcast address.
IP ADDRESSING:
NOTE: If you're not familiar with binary, click
here for a brief primer.
There are three major "types" of Network Addresses, they are:
11111111.00000000.00000000.00000000
255.0.0.0 - Class A (256 Network Addresses : 16,777,215 Host Addresses)
AKA "/8" - Meaning it has 8 bits for it's network mask.
11111111.11111111.00000000.00000000
255.255.0.0 - Class B (65,535 Network Addresses : 65,535 Host Addresses)
AKA "/16" - Meaning it has 16 bits for it's network mask.
11111111.11111111.11111111.00000000
255.255.255.0 - Class C (16,777,215 Network Addresses : 256 Host Addresses)
AKA "/24" - Meaning it has 24 bits for it's network mask.
Yes, I know, there are other types of networks. If you're interested in learning about them (Class D and Class E for example), check
here for a very in depth article by Chuck Semeria.
A subnet is the act of borrowing bits from the host portion of the IP Address and making them part of the network portion.
For example:
A /28 network would be:
11111111.11111111.11111111.11110000
or
255.255.255.240
The explanation is this:
The xxx.xxx.xxx.xxx (dotted decimal notation) is just an easy way to remember the binary version of an IP Address. The binary version is the actual address, Dotted Decimal Notation is only a human readable format of an IP address. So, to make it easier to remember how subnetting works, you have to understand this. Don't think "Class A", "Class B" and "Class C". Instead, think "/8", "/16" and "/24". Remember, the binary version is the IP Address, the Dotted Decimal Notation format is only a mask, or a nickname. So, to explain the above example: At my house, I have a /28 (or, a 255.255.255.240) network. This means I have 16 IP Addresses in my range. Now, because the first and last IP Addresses in ALL address ranges are the network address and the broadcast address (I'll get into that in a second), you only get 14 real addresses. But wait, don't forget, you always need a router (unless you're not connected to any other networks, in which case you would just give yourself an arbitrary /8 so you get a huge amount of addresses), so you really only get 13 useable addresses.