Summary ip addressing

Ip addresses (IPv4) are 32 bits addresses where the first part of the address is the network id and the second part the host number. Two hosts on the same subnet have the same network prefix, two host with the same host number should be on different networks.
To provide companies with ip addresses for different sized networks, classfull addressing is used. (RFC 791) This addressing schema splits the available ip addresses into five classes :

Class A

A class A network can contain the largest number of nodes. It uses the first 8 bits of an ip address for the network (/8 network), the other 24 for the nodes.

(0xxxxxx.nnnnnnnn.nnnnnnnn.nnnnnnnn) x = network, n = nodes.

It exists of networks with ip address of 1 to 127. As class A addresses always start with a 0 bit, there are 2!7 (128) networks available minus the network with all zeros and the loopback address of 127 (01111111) = 126.

There can be a maximum of 16.777.214 (2!24-2) nodes in each class A net. The minus 2 excludes the addresses with all zeros (this network) and all ones (broadcast).  Class A addresses always start with a 0 bit. 

Class B

A class B network uses the first 16 bits (/16 network) of an ip address for the network, the other 16 for the nodes. It exists of the ip addresses starting between 128 and 191 as a class B address always starts with a 1 and a 0 bit.

(10xxxxxx.xxxxxxxx.nnnnnnnn.nnnnnnnn) x = network, n = nodes.

It exists of 2!14 (16384) networks. Each of this network can contain 2!16 (65536) nodes minus the one with all zeros and all ones = 65534. 

Class C

A class C network uses the first 24 bits of an ip address for the network, the other 8 bits are used for the nodes. It exists of the ip addresses starting between 192 and 223. 

(110xxxx.xxxxxxxx.xxxxxxxx.nnnnnnnn) x = network, n = nodes

There are 2!21 (2.097.152) class C networks which can each obtain 254 (2!8 -2) nodes. 

Class D

Class D networks are used for multicast packets. These network addresses are between 224 and 239. It is used for example by the ICMP protocol that sends out router discovery packets to 224.0.0.2 to discover routers on the network. Class D address always start with a 1, a 1 , a 1 and a 0 bit.

Class E

The Class E networks are between 240 and 255. These addresses are not used yet. They start with four 1 bits.

There are 2!(number of masked bits in subnet mask) or 2!(number of masked bits in subnet mask) - 2 networks. The -2 is for the network with all zeros or all ones. Novell Netware 4 and Novell Multiprotocol router can use a network with all zeros.

Subnetting

An ip address can be split into a network ID and a host ID. In a class A address, the network id is based on the first 8 bits, a class B address on the first 16 bits and a class C address on the first 24 bits. For example, an ip address of 10.20.30.40 has a network ID of 10 and a host ID of 20.30.40. 

(nnnnnnnn.hhhhhhhh.hhhhhhhh.hhhhhhhh) n = network id, h = host id.


As class A and B addresses provide lots of hosts addresses subnetting can be used to split these networks into smaller areas. Subnetting is described in RFC 950 and uses bits of the host id the create extra networks. For example, an ip address of 10.20.30.40 with a subnetmask of 255.255.0.0 has 8 bit network id (10), a 8 bit subnet id (20) and a 16 bit host id (30.40)
(nnnnnnnn.ssssssss.hhhhhhhh.hhhhhhhh) -> n = Network id, s = subnet id, = h = host id.

The subnetmask splits the address into the networks (network id + subnet id) and the hosts. Within the subnetmasks the 1's describe the networks, the 0's the hosts.  For example :

11111111.11111111.00000000.00000000 
     255    .  255  .      0      .      0      = Subnetmask. (0.0 is unmasked bits in subnet mask)

There are 2!(number of unmasked bits in subnet mask) -2 nodes per subnet. The -2 is for the nodes with all zeros or all ones. The subnet mask offers routing functionality. E.g if there source address is 10.0.0.1, the target address 10.0.20.15 and the subnet mask 255.0.0.0, the routing function can see the package should stay on the same subnet. In this case the package will be delivered after the ip address has been translated to a MAC address via ARP.
If the subnet mask was 255.255.255.0 (24 bits), then the routing function would see that the target address was on a different net. It would use the ip address for the default gateway, request the MAC address of it via ARP and forward the package to it. Then the router would use it's routing tables to forward the package to the 10.0.20.0 network. 

If you want to create smaller subnets you can expand the subnet mask. This can be done be expanding the default subnet mask (class A -> 255.0.0.0, class B -> 255.255.0.0, class C -> 255.255.255.0) futher to the right. This can be done by adding continuous ones to the subnet mask. E.g the default subnet for a 10.0.0.0 network is 255.0.0.0. If we want to create subnets with 1000 hosts each, we need 10 bits for nodes (2!10 -2 = 1022 nodes) This leaves 22 bits left for the subnet mask from which the first 8 are used as it is a class A network :

(nnnnnnnn.11111111.111111hh.hhhhhhhh) n= network id, 1 = subnet id, h = hosts..

The new subnet mask will be 255.255.252.0. This subnet mask will offer 2!14 -2 = 16.382 subnets. The -2 is for the subnet with all ones and the subnet with all zeros. Subnets with all ones or all zeros are not supported when expanding default subnets. Each subnet can contain 2!10 -2 = 1022 clients.
The first address in first network will be 00001010.00000000.000000100.000000001 (10.0.4.1), the last 00001010.00000000.00000111.11111110 (10.0.7.254). The first address in the second network will be 00001010.00000000.00001000.00000001 (10.0.8.1), the last 00001010.00000000.00001011.11111110 (10.0.11.254)

When choosing an ip address range, keep in mind that for direct (insecure) internet access, public ip addresses are required. These can be bought via www.arin.net or a local ISP. To prevent high costs of multiple public ip addresses, normally only the internet gateway is provided with a public ip address and uses NAT. The internal network uses private ip addresses (RFC 1918) in the range of 10.0.0.1 - 10.255.255.254, 172.16.0.1 - 172.31.255.254 or 192.168.0.1 - 192.168.255.254. Packages send to these addresses are dropped by internet routers.

When defining subnets, each physical location and each WAN needs it's own subnet. The larger the subnet, the more ARP broadcasts take place to convert ip addresses to MAC addresses.

Special addresses

Special addresses are :

bulletNetwork addresses with all zeros. This means 'this network'
bulletNetwork addresses with all ones. This means 'all networks'
bulletNode addresses with all zeros. This means 'this node'
bulletNode addresses with all ones. This means 'all nodes on this network'
bulletNetwork 127. Used for loopback tests.
bulletEntire ip address of all ones. Broadcast to all nodes on current network.
bulletEntire ip address of all zeros. Duplicate ip address.

VLSM (Variable length subnet mask)

If you did get an ip range for your ISP that already has been subnetted, e.g. 24.15.0.0 with subnet 255.255.0.0, you can use VLSM to subnet this subnet. By default you were able to use the 24.15.0.1 to 24.15.255.254 in one subnet. If you want to create 10 extra subnets you need 4 bits (2!4 = 16) so the subnet mask will be 255.255.240.0 

(nnnnnnnn.iiiiiiii.111hhhhh.hhhhhhhh) n = network id, i = add by provider, h = hosts.

The first ip address in the first network will be 00011000.00001111.00100000.00000001 (24.15.32.1), the last in the first network 00011000.00001111.00111111.11111110 (24.15.63.254). The first ip address in the next network will be 00011000.00001111.01000000.00000001 (24.15.64.1), the last in the next network 00011000.00001111.01011111.11111110 (24.15.95.254)

Now that this range is subnetted, on the internet routers will refer to the external address (24.15.0.0 /16), while the top level routers will have routing tables for the internal address (24.15.0.0 /20). 

Usage is VLSM is not supported by RIP v1. RIP v2 and OSPF do support VLSM.

VLSM is described in RFC 1878.

CIDR (Classless InterDomain Routing)/Supernetting

It is also possible to reduce the number of subnets. This is done by using network bits from the subnet mask. For example, default class B addresses (e.g. 130.20.0.0 /16. 130.21.0.0 /16, 130.22.0.0 /16, 130.23.0.0 /16 and 130.24.0.0 /16) can be merged by removing 3 bits (2!3 = 6) from the subnet. The new mask will be 255.248.0.0 (130.20.0.0 /13)

CIDR/Supernetting is not supported by RIP v1.

CIDR/Supernetting is described in RFC 1518 and RFC 1519.

Links

bulletIncreasing the number of ip addresses on a subnet (Q255999)
bulletUsing scopes with different subnet masks in a superscope (Q169291)
bulletIssues with using supernetted ip address ranges (Q281579)
bulletResource kit sample: Introducing to TCP/IP
bulletMS Windows 2000 TCP/IP implementation details
bulletWindows 2000 server deployment guide - Determining network connectivity strategies
bulletIP addressing basics (Windows 2000 magazine)
bulletAre you getting the most out of your subnetting scheme ? (TechRepublic)
bullet Understanding the components of an ip address (TechRepublic)

Last update : 24 July 2001