IPsubnetting is a fundamental subject that’s critical for any IP network engineerto understand, yet students have traditionally had a difficult time graspingit. Over the years, I’ve watched students needlessly struggle through school andin practice when dealing with subnetting because it was never explained to themin an easy-to-understand way. I’ve helped countless individuals learn whatsubnetting is all about using my own graphical approach and calculatorshortcuts, and I’ve put all that experience into this article.

IP addresses and subnets

 

AlthoughIP stands for Internet Protocol, it’s a communications protocol used from thesmallest private network to the massive global Internet. An IP address is aunique identifier given to a single device on an IP network. The IP address consistsof a 32-bit number that ranges from 0 to 4294967295. This means thattheoretically, the Internet can contain approximately 4.3 billion uniqueobjects. But to make such a large address block easier to handle, it waschopped up into four 8-bit numbers, or “octets,” separated by aperiod. Instead of 32 binary base-2 digits, which would be too long to read,it’s converted to four base-256 digits. Octets are made up of numbers rangingfrom 0 to 255. The numbers below show how IP addresses increment.

0.0.0.0
0.0.0.1
…increment 252 hosts…
0.0.0.254
0.0.0.255
0.0.1.0
0.0.1.1
…increment 252 hosts…
0.0.1.254
0.0.1.255
0.0.2.0
0.0.2.1
…increment 4+ billion hosts…
255.255.255.255

Theword subnet is short for sub network–a smaller network within alarger one. The smallest subnet that has no more subdivisions within it isconsidered a single “broadcast domain,” which directly correlates toa single LAN (local area network) segment on an Ethernet switch. The broadcastdomain serves an important function because this is where devices on a networkcommunicate directly with each other’s MAC addresses, which don’t route acrossmultiple subnets, let alone the entire Internet. MAC address communications arelimited to a smaller network because they rely on ARP broadcasting to find theirway around, and broadcasting can be scaled only so much before the amount ofbroadcast traffic brings down the entire network with sheer broadcast noise.For this reason, the most common smallest subnet is 8 bits, or precisely asingle octet, although it can be smaller or slightly larger.

Subnetshave a beginning and an ending, and the beginning number is always even and theending number is always odd. The beginning number is the “Network ID”and the ending number is the “Broadcast ID.” You’re notallowed to use these numbers because they both have special meaning withspecial purposes. The Network ID is the official designation for a particularsubnet, and the ending number is the broadcast address that every device on asubnet listens to. Anytime you want to refer to a subnet, you point to itsNetwork ID and its subnet mask, which defines its size. Anytime you want tosend data to everyone on the subnet (such as a multicast), you send it to theBroadcast ID. Later in this article, I’ll show you an easy mathematical andgraphical way to determine the Network and Broadcast IDs.

The graphical subnet ruler

 

Overthe years, as I watched people struggle with the subject of IP subnetting, Iwanted a better way to teach the subject. I soon realized that many students inIT lacked the necessary background in mathematics and had a hard time with theconcept of binary numbers. To help close this gap, I came up with the graphicalmethod of illustrating subnets shown in Figure A. In this example, we’re looking at a range of IP addresses from 10.0.0.0 up to 10.0.32.0. Note that the ending IP of 10.0.32.0 itself is actually the beginning of the next subnet. This network range ends at the number right before it, which is 10.0.31.255.

Figure A

Notethat for every bit increase, the size of the subnet doubles in length, alongwith the number of hosts. The smallest tick mark represents 8 bits, whichcontains a subnet with 256 hosts–but since you can’t use the first and last IPaddresses, there are actually only 254 usable hosts on the network. The easiestway to compute how many usable hosts are in a subnet is to raise 2 to the powerof the bit size minus 2. Go up to 9 bits ,and we’re up to 510 usable hosts,because 2 to the 9th is 512, and we don’t count the beginning and ending. Keepon going all the way up to 13 bits, and we’re up to 8,190 usable hosts for theentire ruler shown above.

Learning to properly chop subnets

 

Subnetscan be subdivided into smaller subnets and even smaller ones still. The mostimportant thing to know about chopping up a network is that you can’tarbitrarily pick the beginning and ending. The chopping must be along cleanbinary divisions. The best way to learn this is to look at my subnet ruler andsee what’s a valid subnet. In Figure B, green subnets are valid and redsubnets are not.

Figure B

Theruler was constructed like any other ruler, where we mark it down the middleand bisect it. Then, we bisect the remaining sections and with shrinkingmarkers every time we start a new round of bisecting. In the sample above,there were five rounds of bisections. If you look carefully at the edge of anyvalid (green) subnet blocks, you’ll notice that none of the markers containedwithin the subnet is higher than the edge’s markers. There is a mathematicalreason for this, which we’ll illustrate later, but seeing it graphically willmake the math easier to understand.

The role of the subnet mask

 

Thesubnet mask plays a crucial role in defining the size of a subnet. Take a look atFigure C. Notice the pattern and pay special attention to the numbers inred. Whenever you’re dealing with subnets, it will come in handy to remembereight special numbers that reoccur when dealing with subnet masks. They are 255,254, 252, 248, 240, 224, 192, and 128.You’ll see these numbers over and over again in IP networking, and memorizingthem will make your life much easier.

Figure C

I’veincluded three class sizes. You’ll see the first two classes, with host bitlength from 0 to 16, most often. It’s common for DSL and T1 IP blocks to be inthe 0- to 8-bit range. Private networks typically work in the 8- to 24-bitrange.

Notehow the binary mask has all those zeros growing from right to left. The subnetmask in binary form always has all ones to the left and all zeros to the right.The number of zeros is identical to the subnet length. I showed only theportion of the binary subnet in the octet that’s interesting, since all octetsto the right consist of zeros and all octets to the left consist of ones. So ifwe look at the subnet mask where the subnet length is 11 bits long, the fullbinary subnet mask is 11111111.11111111.11111000.00000000. As you can see undermask octet, the subnet mask transitions from 1 to 0 in the third octet.The particular binary subnet mask translates directly to base-256 form as255.255.248.0.

The “mask” in subnet mask

 

Thesubnet mask not only determines the size of a subnet, but it can also help youpinpoint where the end points on the subnet are if you’re given any IP addresswithin that subnet. The reason it’s called a subnet “mask” is that itliterally masks out the host bits and leaves only the Network ID that beginsthe subnet. Once you know the beginning of the subnet and how big it is, youcan determine the end of the subnet, which is the Broadcast ID.

To calculate the Network ID, you simply takeany IP address within that subnet and run the AND operator on the subnet mask.Let’s take an IP address of 10.20.237.15 and a subnet mask of 255.255.248.0.Note that this can be and often is written in shorthand as 10.20.237.15/21because the subnet mask length is 21. Figure D and Figure E show theDecimal and Binary versions of the AND operation.

Figure D
Decimal math
Figure E
Binary math

The binary version shows how the 0s act as a mask on the IP address on top. Insidethe masking box, the 0s convertall numbers on top into zeros, no matter what the number is. When you take theresultant binary Network ID and convert it to decimal, you get 10.20.232.0 asthe Network ID.

One thing that’s always bothered me about theway subnetting is taught is that students are not shown a simple trick tobypass the need for binary conversions when doing AND operations. I even see ITpeople in the field using this slow and cumbersome technique to converteverything to binary, run the AND operation, and then convert back to decimalusing the Windows Calculator. But there’s a really simple shortcut using theWindows Calculator, since the AND operator works directly on decimal numbers. Simplypunch in 237, hit the AND operator, and then 248 and [Enter] to instantly get232, as shown in Figure F. I’ll never understand why this isn’t explained tostudents, because it makes mask calculations a lot easier.

Figure F

Since there are 11 zeros in the subnet mask,the subnet is 11 bits long. This means there are 2^11, or 2,048, maximum hostsin the subnet and the last IP inthis subnet is 10.20.239.255. Youcould compute this quickly by seeing there are three zeros in the third octet,which means the third octet of the IP address can have a variance of 2^3, or 8.So the next subnet starts at10.20.232+8.0, which is 10.20.240.0. If we decrease that by 1, we have10.20.239.255, which is where this subnet ends. To help you visualize this, Figure G shows it on my subnet ruler.

Figure G

IP classes made simple

 

For an arbitraryclassification of IP subnets, the creators of the Internet chose to break theInternet into multiple classes. Note that these aren’t important as far as yoursubnet calculations are concerned; this is just how the Internet is “laidout.” The Internet is laid out as Class A, B, C, D, and E. Class A uses upthe first half of the entire Internet, Class B uses half of the remaining half,Class C uses the remaining half again, Class D (Multicasting) uses up theremaining half again, and whatever is left over is reserved for Class E. I’vehad students tell me that they struggled with the memorization of IP classesfor weeks until they saw this simple table shown in Figure H. This isbecause you don’t actually need to memorize anything, you just learn thetechnique for constructing the ruler using half of what’s available.

Figure H

Remember that allsubnets start with EVEN numbers and all subnet endings are ODD. Note that0.0.0.0/8 (0.0.0.0 to 0.255.255.255) isn’t used and 127.0.0.0/8 (127.0.0.0 to127.255.255.255) is reserved for loopback addresses.

All Class A addresseshave their first octet between 1 to 126 because 0 and 127 are reserved. Class Asubnets are all 24 bits long, which means the subnet mask is only 8 bits long.For example, we have the entire 3.0.0.0/8 subnet owned by GE, since GE waslucky enough to get in early to be assigned 16.8 million addresses. The U.S.Army owns 6.0.0.0/8. Level 3 Communications owns 8.0.0.0/8. IBM owns 9.0.0.0/8.AT&T owns 12.0.0.0/8. Xerox owns 13.0.0.0/8. HP owns 15.0.0.0/8 and16.0.0.0/8. Apple owns 17.0.0.0/8.

All Class B addresseshave their first octet between 128 and 191. Class B subnets are all 16 bitslong, which means the subnet masks are 16 bits long. For example, BBNCommunications owns 128.1.0.0/16, which is 128.1.0.0 to 128.1.255.255. CarnegieMellon University owns 128.2.0.0/16.

All Class C addresseshave their first octet between 192 and 223. Class C subnets are all 8 bits long,so the subnet mask is only 24 bits long. Note that ARIN(the organization that assigns Internet addresses) will sell blocks of fourClass C addresses only to individual companies and you have to really justifywhy you need 1,024 Public IP addresses. If you need to run BGP so you can usemultiple ISPs for redundancy, you have to have your own block of IP addresses.Also note that this isn’t the old days, where blocks of 16.8 million Class Aaddresses were handed out for basically nothing. You have to pay an annual feefor your block of 1,024 addresses with a subnet mask of /22, or 255.255.252.0.

The concept of subnetclasses can cause harm in actual practice. I’ve actually seen people forget toturn classes off in their old Cisco router and watch large subnet routes gethijacked on a large WAN configured for dynamic routing whenever some routeswere added. This is because a Cisco router will assume the subnet mask is thefull /8 or /16 or /24 even if you define something in between. All newer CiscoIOS software versions turn off the concept of subnet classes and uses classlessrouting by default. This is done with the default command “IPClassless.”

Public versus private IP addresses

 

Besides the reservedIP addresses (0.0.0.0/8 and 127.0.0.0/8) mentioned above, there are otheraddresses not used on the public Internet. These private subnets consistof private IP addresses and areusually behind a firewall or router that performs NAT (network address translation).NAT is needed because private IP addresses are nonroutableon the public Internet, so they must be translated into public IP addressesbefore they touch the Internet. Private IPs are neverrouted because no one really owns them. And since anyone can use them, there’sno right place to point a private IP address to on the public Internet. PrivateIP addresses are used in most LAN and WAN environments, unless you’re luckyenough to own a Class A or at least a Class B block of addresses, in which caseyou might have enough IPs to assign internal andexternal IP addresses.

The following blocksof IP addresses are allocated for private networks:

  • 10.0.0.0/8  (10.0.0.0 to 10.255.255.255)
  • 172.16.0.0/12  (172.16.0.0 to172.31.255.255)
  • 192.168.0.0/16  (192.168.0.0 to192.168.255.255)
  • 169.254.0.0/16  (169.254.0.0 to169.254.255.255)*

*Note that169.254.0.0/16 is a block of private IP addresses used for random self IPassignment where DHCPservers are not available.

10.0.0.0/8 is normallyused for larger networks, since there are approximately 16.8 million IPaddresses available within that block. They chop it up into lots of smallergroups of subnets for each geographic location, which are then subdivided intoeven smaller subnets. Smaller companies typically use the 172.16.0.0/12 range,chopped up into smaller subnets, although there’s no reason they can’t use10.0.0.0/8 if they want to. Home networks typically use a /24 subnet within the192.168.0.0/16 subnet.

The use of private IPaddresses and NAT has prolonged the life of IPv4 for the foreseeable futurebecause it effectively allows a single public IP address to represent thousandsof private IP addresses. At the current rate that IPv4 addresses are handedout, we have enough IPv4 addresses for approximately 17 years.ARIN is much more stingy now about handing them out, and small blocks of IPaddresses are relatively expensive compared to the old days, when companieslike Apple were simply handed a block of 16.8 million addresses. The nextversion of IP addresses, called IPv6,is 128 bits long–and there are more than 79 thousand trillion trillion times more IP addresses than IPv4. Even if youassigned 4.3 billion people on the planet with 4.3 billion IP addresses each,you would still have more than 18 million trillion IPv6 addresses left!

 

Source by : http://www.techrepublic.com

IP CALC

About these ads