[Techtalk] Classes of IP-adresses

Raven, corporate courtesan raven at oneeyedcrow.net
Tue Aug 28 13:09:04 EST 2001

Heya --

Quoth Mette Lund (Tue, Aug 28 2001 at 05:11:27P +0200):
> Do anyone know _why_ they are called class A (1.*.*.*-126.*.*.*), class 
> B (128.1.*.*-191.254.*.*),  class C (192.0.1.*-223.255.254.*), and D 
> (224.*.*.*-255.*.*.*)?
> I've tryed looking on the net, but I can't find the answer I'm looking for.

	Not sure quite what you're looking for, but I'll give it a go.  If you're wondering why it was class A, B, C, D, and E instead of 1, 2, 3, 4, and 5, I have no idea.  They probably just picked the letters as a convenient way to represent the different classes of address space.

	If you're wondering why the numbers terminate on those boundaries, that I can help you with.  When you translate an IP address into binary form, each octet becomes eight digits, each of which is a 0 or a 1.  The first series of digits of the first octet was used to distinguish which address class the IP address belonged to.  Let's look at some examples.

	Each bit in an octet represents a different value.  Add together the values of all bits represented by a 1, and you'll have the decimal value of that octet.  The bit values start at 1 and double every time, moving from the right.  So you have

	0     0     0     0     0     0     0    0   bits
	128   64    32    16    8     4     2    1   values is a Class A address.  When you put it in binary, it's

	0     1     1     0     1     0     0     0
        128   64    32    16    8     4     2     1

	So 64 + 32 + 8 = 104, the first octet of  You can do this for any IP address.  The binary value of the first octet is all that matters for classful addressing.

	A class A address is one whose first octet starts with 0 in binary.  This can be anything from 00000001 to 01111111, which, if you add them up, is anything from 1 to 127.  ( is reserved for loopback addresses, so that's why it's listed as 1 to 126.)

	A class B address is one whose first octet starts with 10 in binary.  This can be anything from 10000000 to 10111111, which turns out to be 128 to 191.

	A class C address is one whose first octet starts with 110 in binary (11000000 to 11011111), which is 192 to 223 in decimal.

	Likewise, the seldom-used Class D addresses start with 1110 in binary (11100000 to 11101111 -- 224 to 239) and the Class E's start with 11110 (11110000 to 11110111 -- 240 to 247).

	A netmask is used to represent how much of an IP address is used to represent the network, and how much is used to represent the individual machine on that network.  Any bit represented by a 1 in the netmask is used to represent the network, and any bit that's a 0 in the netmask is used to represent the individual machine.

	So let's take the IP address, and say it has a netmask of  This means that the netmask in binary is
11111111.11111111.11111111.00000000.  So the network this machine is on is, and this machine is the 32nd available IP in that block of 256 possible (256 possible values of that last octet that represents individual machines.)  You'll always lose 2 IPs in any given netblock -- the lowest (in this case, will represent the network, and the highest (in this case will represent the broadcast address, a special IP used to contact all machines in a given netblock.  That leaves 254 IP addresses in this block that you can assign to machines -- 254 routable IPs.

	There are standard netmasks that go along with these --Class A's have a netmask of, Class B's have a netmask of, and Class C's have a netmask of  However, most ISPs nowadays use classless routing instead of using these classes, because it saves IP address space.  IP addresses are in great demand now, and the agencies that allocate them are getting stricter in their requirements to give you a block.  So, most places have moved to using CIDR, or Classless Interdomain Routing.

	CIDR represents the netmask as the number of bits in the netmask that are 1's, counting from the left.  So, the traditional Class A netmask of becomes
11111111.00000000.00000000.00000000 in binary, and
/8 in CIDR.

Likewise, your Class B netmask becomes
11111111.11111111.00000000.00000000 in binary, and 
/16 in CIDR

	Now what, you're asking, is so cool about that?  The great thing about CIDR is that you can make netblocks of many more sizes.  So, if you need a netblock for about 1,000 hosts, you can have one much closer to the size you need.  Under the classful system, you'd need a Class B address, since there are only 254 routable IPs in a Class C.  A Class B will give you 65,534 routable IPs.  But I only need 1,000!  A Class B would be a huge waste of IP space.

	With CIDR, the provider can assign me a block with a netmask of, which is
11111111.11111111.11111100.00000000 in binary, and a 
/22 in CIDR

This will give me 1022 routable IPs.  I think you'll agree that this is a much better fit for my needs, and doesn't waste IP space.

	I realize that this is the quickie explanation -- if anything here doesn't make sense, please ask and I'll elucidate.


"HARLOT!" "Slut!" "Hooooooo-er!" "Lawyer!" "Social Studies teacher!" "DMV
 worker!"  "AOL user!"
"You win."
"That was pretty vicious.  I'm sorry."
 -- Alex and me, hurling insults at work

More information about the Techtalk mailing list