Getting Started with IPv4 Subnetting

I’m studying for the MS 70-411 test now, and it includes some IPv6 routing and transition technology. It also includes some remote connection technologies like Direct Access and VPN. Studying made me realize that I didn’t actually know that much about IPv4. Here’s the scoop.

Things an Admin Should Know Regarding IPv4

  • How to convert a CIDR network address into an IP + subnet mask.
  • How to convert from an IP + Subnet notation into CIDR notation.
  • How to calculate the starting and ending addresses of a network.

CIDR into an Subnet Mask

To convert CIDR into an IP range, do the following:

  1. Take the number after the slash. This is the network prefix. Write out a string of the character ‘1’ until you’ve written the same number of characters as the prefix is. Put a period (dot) every 8 characters.
  2. Finish off the line with “zero’s” until you have a total of 32 characters.
  3. Convert the line of “one’s” from binary into decimal. This is your subnet mask.

Example time:

For the network 192.168.111.240/29:

Step 1 – write 29 “one’s”

11111111.11111111.11111111.11111

Step 2 – fill the line with “zero’s” until we reach 32 characters:

11111111.11111111.11111111.11111000

Step 3 – Convert to decimal.

11111111 = 255

11111000 = 248

Result: 255.255.255.248.

The subnet mask for 192.168.111.240/29 is 255.255.255.248.

Subnet Mask into CIDR

To convert a subnet mask into CIDR slash notation, we just run the process backwards.

  1. Convert the subnet mask into binary.
  2. Count the number of “one” characters. This is your CIDR slash number.

Example:

address 192.168.111.240, subnet mask 255.255.255.248

Step 1 – convert the subnet mask to binary:

11111111.11111111.11111111.11111000

Step 2 – count the “one’s”.

There are 29 one’s. Therefore, our CIDR address is 192.168.111.240/29.

Calculating the Starting and Ending Addresses

Finding the starting and ending addresses of the network:

  1. Write out the network address in binary.
  2. Look the number CIDR address. After the ‘/’ is a number. Write  a ‘1’ under each character of the binary network address, until they add up to the number after the ‘/’.
  3. Perform an ‘And’ operation between the binary network address and the line of “one’s”, and then convert the result from binary to decimal. This is your starting address.
  4. Perform an ‘Or’ operation between the binary network address, and the inverse of the line of “one’s”, and then convert from binary to decimal. This is your ending address.

Example time!

Let’s calculate the IP Range for the network 192.168.111.240/29.

Step 1

Write out the network address in binary:

192 = 11000000

168 = 10101000

111 = 01101111

240 = 11110000

result:

11000000.10101000.01101111.11110000

Step 2

Take the number after the ‘/’ in the CIDR address, and add that many “1’s” beneath the binary address:

11000000.10101000.01101111.11110000

11111111.11111111.11111111.11111000

Step 3

Calculate the starting address with an ‘And’ bitwise operation.

An ‘and’ operation can be thought of as vertical multiplication. Only 1 * 1 = 1. All else is zero:

11000000.10101000.01101111.11110000

And

11111111.11111111.11111111.11111000

Result:

11000000.10101000.01101111.11110000

Convert to decimal:

Our starting address is: 192.168.111.240

Step 4

Calculate the ending address with an ‘Or’ bitwise operation.

The ‘or’ operation takes the highest number. If both characters are ‘0’, then the result is ‘0’. Otherwise, the result is ‘1’. Before performing the ‘Or’, we need to invert the line of “one’s”.

Binary Starting Address: 11000000.10101000.01101111.11110000

Line of One’s: 11111111.11111111.11111111.11111000

Inverted line of One’s: 00000000.00000000.00000000.00000111

Now, let’s do the Or.

11000000.10101000.01101111.11110000

OR

00000000.00000000.00000000.00000111

Result:

11000000.10101000.01101111.11111111

Convert to decimal.

Our ending address is: 192.168.111.255

Conclusion

We learned that the network address 192.168.111.240/29 is equilavent to 192.168.111.240-192.168.111.255.

I realize that this is IP basics, but everyone starts somewhere. I actually had difficulty finding this information online in a concise format. Hopefully this helps.

For practice, see this awesome site:

Subnetting Questions

Enjoy.

Advertisements

One thought on “Getting Started with IPv4 Subnetting

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s