Networking 101: Subnets Realized (Including IPv6)
ARP, broadcast storms, layer 2 loops, and other mysteries explained
What's the point of creating subnets anyway? How do I remember those strange looking subnet masks? How the heck does this work with those crazy looking IPv6 addresses? This edition of Networking 101 will expand on the previous Subnets and CIDR article, in the interest of promoting a thorough understanding of subnetting.
The most common erroneous configuration happens when someone configures an IP address without specifying the netmask and broadcast address. For some reason, most operating systems don't take the liberty of updating these things, even though one can be determined from the other. If you run 'ifconfig eth0 126.96.36.199 netmask 255.255.255.0' you might expect that everything is ready to go. Unfortunately, it's very likely that your broadcast address was set to 255.255.0.0. It largely depends on the router's configuration, but normally this results in all broadcast packets being dropped. Conversely, if the netmask is configured incorrectly, the computer wouldn't know where the subnet starts and begins. If a computer thinks a host is on the same subnet when it actually isn't, it will attempt to ARP for it instead of the router. Routers can be configured to handle this and pretend they are the host (called Proxy Arp), but normally the result is unreachable hosts.
What about 188.8.131.52/255.255.255.248? We're definitely in a land smaller than the /24 subnet. If we look at the remaining bits in the last octet, we can see that there are eight IP addresses available. Remember that only 2^3 can make eight, so we're using all but three bits in the network portion. This is a /29 network. Of course, the easy ones are pretty clear: 255.255.255.128 allows half as many host addresses in the last octet compared to the /24 network, so it's a /25.
On the topic of confusing netmasks, IPv6 addresses certainly have a place. The netmask isn't really an issue—the same concept applies, just with larger numbers to remember. The real problem lies within the address representation itself; the IETF seemed to take pride in creating confusion. Typically an IPv6 address is represented in hex, or base-16. Our old friend IPv4 could represent an IP address in hex too, which would look like B.B.B.B for the address 184.108.40.206. Unfortunately, IPv6 isn't quite that nice looking. To represent 128 bits, IPv6 normally breaks up the address into eight 16-bit segments.
An IPv6 address looks like: 2013:4567:0000:CDEF:0000:0000:00AD:0000. It does get a bit easier. For example, leading zeros are not written, and contiguous quads of zeros get collapsed to ::. Trailing zeros, however, must be shown. This is a bit confusing, but the rules always allow for a non-ambiguous IP address. Leading zeros in each quad can always be removed, but the collapsing of contiguous blocks of zeros can only happen once per address. The above address with collapsed zeros will look like: 2013:4567:0000:CDEF::AD:0000. IPv6 provides 2^128 addresses, more than enough to allocate roughly 1000+ IP addresses per square meter of Earth.
If you remember the rules of binary, the address representation rules with IPv6, and a few simple subnets for reference, you'll be Master of Subnets - the one everyone asks for help.
When he's not writing for Enterprise Networking Planet or riding his motorcycle, Charlie Schluting is the Associate Director of Computing Infrastructure at Portland State University. Charlie also operates OmniTraining.net, and recently finished Network Ninja, a must-read for every network engineer.
Article courtesy of Enterprise Networking Planet, originally published July 1, 2008.