IP Addresses, Subnet Masks, & Subnetting

An IP address is used for Network Layer identification of hosts and routers on a TCP/IP network. The address consists of a 32-bit binary number of 4 octets and is usually displayed in the decimal format 100.100.100.100, which is called dotted decimal notation.

The class of the Network is determined by the high order bits

Class
1st Octet Range 
High Order Bits
A
1-126
000.000.000
B
128-191
100.000.000
C
192-223
110.000.000.000

Bitwise ANDing

Hosts and routers use Boolean math to determine the netid and the hostid by the use of ANDing.

Bit 1 Bit 2 Result 
1 1 1
1 0 0
0 1 0
0 0 0

ANDing IP Addresses and Subnet Masks

198.53.147.45 11000110 00110101 10010011 00101101
255.255.255.0 11111111 11111111 11111111 00000000
Result 11000110 00110101 10010011 00000000
         

Note: In all calculations and comments the current classful standard is used. Under this standard, the first and last subnets are dropped.

The higher order bits of 198.53.147.45 are 110 thus this is a class C address

The Netid of this Class C address 198.53.147.0 and the Hostid is 45

From the example above it is visible that with this subnet mask the netid and hostid remained unchanged by bitwise ANDing.

Defining a Subnet Mask

Subnetting is a technique that allows the network administrator to divide a network into smaller networks by using the same network number assignment. The advantages of subnetting are below:

In the diagram above illustrates how a subnetted IP appears on an internal Intra-Net and the Internet. The Internet only reads the NetId and the routers on the Internet are only concerned with routing the IP packet to the Intra-Net external router. When the IP packet reaches the external router, which has been configured for subnet routing reads the HostId. The router then forwards the packet to appropriate subnet where it is delivered to the host.

Determining the Subnet Mask to Use

The diagram below shows that when subnetting an IP address the Netid remains unchanged but the Hostid is further sectioned or divided up.

The Current Classfull Standard

There a number of different ways to define the available range of IP addresses. The MCSE exams use the existing Classful standard. Some network equipment may follow a more current addressing scheme called CIDR. To date, CIDR has not been adopted as the standard."

Just for reference, MS stacks do not adhere to the Classful standard. They will allow you to use all subnets, including the first and last. For example, look at the KB article, Q139983 "Class C Subnetting Options for RAS Routing"

The Current Classfull Standard rules are as follows.

  1. The original Network ID (defined by the default class mask)
  2. The Subnet ID (defined by any bits beyond the default class mask)
  3. The Host ID

Before defining a subnet mask, you need to determine the number of segments and hosts per segment

Bit Pattern Masked Bits Provided Subnets Subnet Mask
11000000 2 2 192
11100000 3 6 224
11110000 4 14 240
11111000 5 30 248
11111100 6 62 252
11111110 7 126 254
11111111 8 254 255

The above chart represents how a subnet mask is represented in binary format, to determine the values is quite simple

  1. Determine the number of Physical segments required in your network and covert to binary format. In the example below 6 segments are required
  2. Count the number of bits required to represent the number of physical segments in binary. With 6 required subnets (Binary value is 110). Representing 6 in binary requires 3 bits
  3. Convert the required number of bits to decimal format in high order (left to right).
  4. Configure the 3 required bits as the first bits of the host id. The decimal value for binary 11100000 is 224. Representing a subnet mask of 255.255.255.224

Question: What happened to 198.53.147.32 and 198.53.147.63 why can't these be IP addresses ?

198.53.147.32 - Is the subnet's Network Id which is revserved for the physical segment (00100000).
198.53.147.63 - Is the subnet's Broadcast Address (00111111)

As stated above every network or subnet has a IP address for the Physical segment and a Broadcast Address.

Calculating Hosts

Bit 
Pattern
Masked 
Bits
Provided 
Subnets
Subnet 
Mask
Class A 
Hosts/Subnet
Class B
Hosts/Subnet
Class C 
Hosts/Subnet
11000000 2 2 192 4,194,301 16,382 62
11100000 3 6 224 2,097,150 8190 30
11110000 4 14 240 1,048,574 4,094 14
11111000 5 30 248 524,286 2,046 6
11111100 6 62 252 262,142 1,022 2
11111110 7 126 254 131,070 510 0
11111111 8 254 255 65,534 254 0

Question: I want to set up a TCP/IP LAN in my organization what IP addresses should I use?

For hosts that need to be connected to the Internet you can get a block of valid IP addresses from a ISP. Larger Organizations or ISP's can get IP blocks from the American Registry for Internet Numbers

The following IP address ranges have been set aside for Internal use. These IP's are will not be routable on the Internet.

Class A: 10.xx.xx.xx
Class B: 172.16.xx.xx - 172.32.xx.xx
Class C: 192.168.xx.xx

Relevant RFC's

RFC 917 - Internet Subnets

RFC 950 - Internet Standard Subnetting Procedure

RFC 1517-Applicability Statement for the Implementation of Classless Inter-Domain Routing (CIDR)

RFC 1518- An Architecture for IP Address Allocation with CIDR

RFC 1519- Classless Inter-Domain Routing (CIDR): An Address Assignment and Aggregation Strategy

RFC 1520- Exchanging Routing Information Across Provider Boundaries in the CIDR Environment

RFC 1878 - Variable Length Subnet Table For IPv4