I didn’t write this, but it is a good breakdown on IP address creation and existence. This is a copy-and-paste of an email I received from a magazine but I figured it’d help those that are learning IP addressing. (Mine was learned through 3COM documentation in 1996, which read about the same way)
NOTE: This is IPv4, NOT IPv6.
START!
—————
More on IP Address Classes
So, you’ve decided it isn’t good enough anymore to just know IP addresses are on the Network Layer of the OSI model, you want to apply that knowledge. This path will ultimately lead you to subnetting. For now, let’s separate the IP classes.
Remember that every IP address is 32 bits long and is divided into four (the quartet) octets arranged in dotted-decimal notation. An octet is 8 bits. This is one way look at an IP address:
216.77.133.249
Here’s another:
11011000.01001101.10000101.11111001
It May not look it, right off the bat, but it’s the same number. The first one is in decimal, the second is in binary. The IP address represented above in binary above contains four octets; the eight bits clearly designated (not so easily recognized in decimal). The position of each bit represents the binary number in powers of 2, like so:
2^7 = 128
2^6 = 64
2^5 = 32
2^4 = 16
2^3 = 8
2^2 = 4
2^1 = 2
2^0 = 1
Placing a 1 in any position turns it “on.” And remember, in binary, the only language a computer knows, on = 1, off = 0. So, returning to our example above, the first octet in the decimal version of the IP address, it comes out as:
1 = 128
1 = 64
0
1 = 16
1 = 8
0
0
0
So 128 + 64 + 16 + 8 = 216, which was the first octet (in decimal) in the IP address.
The highest possible value, in decimal, of each octet is 255:
128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255.
When all the bits are “on” you get 11111111. When all the bits are “off” you get 00000000. So, a binary IP address of 11111111.11111111.11111111.11111111 will be, in decimal, 255.255.255.255 (a flooded broadcast). On the other hand, a binary IP address of 00000000.00000000.00000000.00000000 will be, in decimal, 0.0.0.0, which in a routing table represents an unknown network or host, and is typically used to designate the default gateway of last resort.
In theory, the 32-bit IP addressing scheme supports up to 3,720,314,628 hosts. In reality, it won’t go that high. Generally, there will be only as many IP addresses as may be designated by the three most common classes of IP addresses, A, B and C. There are two more classes, D & E, but they are used for multicast and experimental purposes respectively, so we won’t get into those here.
The classes are split based on the number in the first Octet. It breaks down like this:
Class First decimal value. Just as an aside, you’ll notice the Class A IP address ends in 127 but that value really is not to be used. 127.0.0.1 is a special Class A address used for internal loopback testing and will generate no network traffic. Ping it sometime and you’ll see what I mean.
Now, those are the decimal values. Get ready for a shock. Spotting IP address classes is even easier in binary. Each class can be identified by looking at the high order bits (the digits at the left end of the octet) and figuring out where the first zero falls, that is where the first “off” bit is. In Class A addresses, the very first high order bit is always off. In Class B, the second high order bit is always off, the first is on. In Class C, the third high order bit is always off, the first two are always on. That breaks down like this:
Class High Order Bit Value. So, when we look at our above example again, in decimal: 216.77.133.249 and in binary 11011000.01001101.10000101.11111001
In decimal, we see the value in the first octet is 216, which means it’s a Class C IP Address. In binary, we look at the high order bits in the first octet and see that
the first high order bit to be off (or 0) is the third one, so this is a Class C address.
Knowing the class is important because that will determine your default subnet. It also will indicate the network and host portions of each address. The default subnet mask for a Class A IP address is 255.0.0.0; Class B is 255.255.0.0 and Class C is 255.255.255.0. By coincidence, (yeah, you bet!) the network portion of a Class A IP address is the first octet. In Class B, it’s the first two octets. In class C, it’s the first three octets. In all three cases, the host number follows the network portion of the address.
The network portion of any IP address uniquely identifies the network to which the address belongs. Every workstation, every piece of equipment that can be assigned an IP address, will share the network portion in its IP address.
By contrast, the host address (also called a node address) is assigned to and uniquely identifies each device on the network. Unlike the network portion, this part of the address must be unique because it identifies a particular machine.
Subdividing an IP address into network and host portions is determined by the address’ class. So, looking again at our example to determine the network and host portions, we know that this is a Class C IP address, which means the first three Octets will be the network portion.
Within each IP address class is a set of addresses set aside for use in local networks behind a firewall or Network Address Translation (NAT) device or for networks that don’t access the Internet. Those addresses are:
Class Special Local Network Address
All hosts on a network must have the same network ID in order to communicate. So, in this case, all the hosts belong to the network address 216.77.133.0.
In case you’re wondering how those max number of networks and max number of hosts were arrived at, it’s 2 to the power of the number of bits in the respective address minus 2. For instance, there are 24 bits in the host portion of an Class A IP address. 2^24 = 16,777,216. Now you subtract 2 because addresses with the patterns of all 1s or all 0s are reserved. So the real max number of hosts possible in a Class A address is 16,777,214
A number of addressing rules governing IP Address classes and they include:
* The network and the host ID bits cannot all be 0’s (0.0.0.0) because that would mean only the local network.
* The first Octet is never 000 (decimal).
* Networks connected by routers need unique network IDs.
* Networks connected to the Internet need to have unique network IDs assigned by InterNIC.
If ever you decide you need some IP addresses, go to ARIN (American Registry of Internet Numbers). ARIN will assign you a number based on network size and class. Typically, these assignments come directly from ARIN and are given only to Internet Service Providers (ISPs) and very large companies.