Subnetting

 

Subnetting is used to divide a single network into multiple smaller ones. This allows you to use routers to control traffic between networks. When you configure a network, you receive a range of IP addresses from your ISP or you use internal addressing that are not routable. If you have multiple physical locations or a large single location, you need to subnet the address range you are using for easier network management.

 

IP addresses are viewed using dotted decimal notation (i.e. 10.10.2.238 reads ten dot ten dot two dot two-three-eight), but in order to truly understand subnetting you need to be about to use binary notation. Why? Because when data is routed from one network to another it is routed using binary numbers, not decimal numbers.

 

Why Subnet?

 

A single network is fine for a small company with a limited number of computers in a limited location. However, if a company has many larger networks spread among a number of geographical locations, subnetting is going to be necessary. Using subnetting splits one large network into a number smaller, easier to manage networks. Subnetting can:

*       Reduce collisions

o        As you (hopefully) recall, Ethernet networks use CSMA/CD as an access method. If two computers attempt to transmit data at the same time, a collision occurs. The more computers on a network subnet, the more collisions. Collisions slow down communication within in a network. When a collision occurs each computer waits a random period of time before attempting to send data again.

o        On a very large network the actual throughput may be only 30% to 40% of capacity because of loss due to collisions. In other words, a 10 Mbps network might only run at 3-4 Mbps due to collision activity.

o        Subnetting a network reduces network traffic by isolating traffic to specific network segments, reducing collisions.

*       Limit broadcast messages which take up bandwidth

o        Broadcast messages are generated by a number of network services. A broadcast message is received by all computers on a network. For example, on a DHCP network when a computer logs in it sends broadcast messages out looking for a DHCP server. When there are few computers on a network, this is no big deal. As the network grows, though, broadcast messages may slow down the network substantially.

o        Broadcast messages are addressed to the IP address 255.255.255.255. This address is processed by every single computer on the network.

o        Broadcast messages are not sent across subnets because routers do not forward packets sent to the 255.255.255.255 address. Therefore, subnetting a network will isolate broadcast messages within a subnet, reducing broadcast traffic.

*       Control traffic and bandwidth use

o        When a network is subnetted routers are placed between subnets for passing traffic from one network to another. Subnetting a network allows you to control what traffic goes where.

 

Binary and TCP/IP

 

IP addresses are expressed in dotted decimal notation. It’s easier for people to use and the software can convert it to binary for the network. However, networks must read all IP addresses in binary. Therefore, you need to be able to convert an IP address from dotted decimal notation to binary notation for custom subnetting. If you need to review how to convert decimal numbers to binary and binary to decimal, please access the document at http://teechur.msvl.k12.wa.us/w2svr/unit15/binary.htm.

 

Binary and Subnet Masks

 

When we think of subnet masks, we think of them in dotted decimal notation because that’s how we enter them into the TCP/IP properties. However if you convert a ddn subnet mask into binary you’ll see how the masking actually works.

 

For example the subnet mask 255.255.254.0 can be re-written in binary to be:

11111111.11111111.11111110.00000000

 

Look at the following subnet masks

255.255.255.0

11111111.11111111.11111111.00000000

255.255.252.0

11111111.11111111.11111100.00000000

255.255.240.0

11111111.11111111.11110000.00000000

 

Notice how the 1s and the 0s are all grouped together? This is where the masking takes place. The 1s mask off, or identify, the network part of the IP address. The 0s identify the host (individual computer or node) part of the IP address.

 

So to learn what part of an IP address is the host ID and what part is a network ID you do the following:

 

  1. Convert the IP address into binary.
  2. Convert the subnet mask into binary.
  3. Line them up. The numbers in the IP address corresponding with the 1s are the network Ids.
  4. The numbers in the IP address corresponding with the 0s are the host Ids.

 

See the example below.

 

 

Decimal

Binary

IP Address

192.168.5.20

11000000.10101000.00000101.00010100

Subnet Mask

255.255.255.0

11111111.11111111.11111111.00000000

Network ID

192.168.5.0

11000000.10101000.00000101.00000000

Host ID

0.0.0.20

00000000.00000000.00000000.00010100

 

The process your computers uses to find the network ID is called ANDing. This is a mathematical operation that compares two binary digits and gives a result of 1 or 0. If both binary digits being compared have a value of 1, the result is 1. If one digit is 1 and the other 0, or both are 0 then the result is 0.

 

Recap

*       1 and 1 = 1

*       1 and 0 = 0

*       0 and 0 = 0

 

Practice ANDing

 

Find the network ID of several IP addresses based on a given subnet mask

 

 

Decimal

Binary

IP Address

130.179.16.67

 

Subnet Mask

255.255.255.0

 

Network ID

 

 

Host ID

 

 

 

 

Decimal

Binary

IP Address

10.10.238.2

 

Subnet Mask

255.224.0.0

 

Network ID

 

 

Host ID

 

 

 

 

Decimal

Binary

IP Address

130.179.16.67

 

Subnet Mask

255.255.0.0

 

Network ID

 

 

Host ID

 

 

 

Address Classes Review

 

There are 5 different address classes. You can determine which class any IP address is in by examining the first 4 bits of the IP address.

Class A addresses begin with 0xxx, or 1 to 126 decimal.

Class B addresses begin with 10xx, or 128 to 191 decimal.

Class C addresses begin with 110x, or 192 to 223 decimal.

Class D addresses begin with 1110, or 224 to 239 decimal.

Class E addresses begin with 1111, or 240 to 254 decimal.

 

Addresses beginning with 01111111, or 127 decimal, are reserved for loopback and for internal testing on a local machine. [You can test this: you should always be able to ping 127.0.0.1, which points to yourself] Class D addresses are reserved for multicasting. Class E addresses are reserved for future use. They should not be used for host addresses.

 

Now we can see how the Class determines, by default, which part of the IP address belongs to the network (N) and which part belongs to the node (n).

Class A -- NNNNNNNN.nnnnnnnn.nnnnnnn.nnnnnnn

Class B -- NNNNNNNN.NNNNNNNN.nnnnnnnn.nnnnnnnn

Class C -- NNNNNNNN.NNNNNNNN.NNNNNNNN.nnnnnnnn

 

In the example, 140.179.220.200 is a Class B address so by default the Network part of the address (also known as the Network Address) is defined by the first two octets (140.179.x.x) and the node part is defined by the last 2 octets (x.x.220.200).

 

Subnetting a Network

To subnet a network, you take some bits from the host ID and give them to the network ID. As the manager of a network, you have the power and freedom to do this. (Feel the power. FEEL THE POWER!)

 

A Class B address is very large and generally needs to be subnetted to handle routing between different physical locations. To keep subnetting simple, bits are often taken from the host ID in a group of eight. This keeps the entire octet in intact. The table below shows an example of subnetting a Class B address by taking eight bits from the host ID and giving them to the network ID. Using an entire octet for subnetting gives you 256 possible subnets. Traditionally the subnets using all 0s or all 1s are discarded, leaving 254 usable subnets.

 

 

Decimal

Binary

Original network

135.25.0.0

10000111.00011001.00000000.00000000

Original subnet mask

255.255.0.0

11111111.11111111.00000000.00000000

New subnet mask

255.255.255.0

11111111.11111111.11111111.00000000

Subnet 1

135.25.0.0

10000111.00011001.00000000.00000000

Subnet 2

135.25.1.0

10000111.00011001.00000001.00000000

Subnet 3

135.25.2.0

10000111.00011001.00000010.00000000

Subnet 4

135.25.3.0

10000111.00011001.00000011.00000000

Subnet 5

135.25.4.0

10000111.00011001.00000100.00000000

Subnet 6

135.25.5.0

10000111.00011001.00000101.00000000

Subnet 7

135.25.6.0

10000111.00011001.00000110.00000000

Subnet 256

135.25.255.0

10000111.00011001.11111111.00000000

 

Doing this instead of having one great big network, you can subnet into a bunch of smaller networks. The problem is, we rarely need 256 extra networks, and each of those networks has a very limited number of nodes available. Not a lot of use for 256 (or 254 assuming you don’t use all 1s or all 0s) teensy little networks, is there?

 

So instead you’ll generally “borrow” only the number of bits you need. This is called custom subnetting. In this case you use only SOME of the octet to get the number of networks you need.

 

Example: Your company leased the class B address 173.25.0.0. This is way too large for one network. You need to split it into ten networks.

 

To calculate the numbers of subnets that can be created by a certain number of bits use the formula 2n-2. In this formula n represents the number of bits and -2 is used because we generally do not use all 1s or all 0s in our subnets, so we subtract 2 un-useable networks. So let’s try the formula!

 

2n-2>=10 (In other words, 2n-2 has to be greater than or equal to 10)

2n>=10+2

2n>=12

26=64

6 is too big so let’s try 5

 

2n>=10+2

2n>=12

25-=32 since 2x2x2=8 23 would be too small, but 24 is just right.

 

To keep from having to use a calculator, just use this table. Looking at the table we can easily see that 5=32 which, even when we subtract 2, is larger than or equal to 10.

 

x

2x

2x in Decimal

0

20

1

1

21

2

2

22

4

3

23

8

4

24

16

5

25

32

6

26

64

7

27

128

8

28

256

 

 

 

Decimal

Binary

Original network

173.25.0.0

10101101.00011001.00000000.00000000

Original subnet mask

255.255.0.0

11111111.11111111.00000000.00000000

In order to create ten smaller networks we’re going to borrow 4 bits from the host ID.

New subnet mask

255.255.240.0

11111111.11111111.11111000.00000000

(convert the middle octet to binary)

Subnet 1

173.25.0.0

10101101.00011001.00000000.00000000

Subnet 2

173.25.8.0

10101101.00011001.00001000.00000000

Why do we put 8 in the third octet? Because starting with the end of that octet we find where the first 1 from the right sits in place value. It sits in the 8s place, so we use that number for our network address for our first subnet. We then increase that octet by 8 for each subsequent network.

Subnet 3

173.25.16.0

10101101.00011001.00010000.00000000

Subnet 4

173.25.24.0

10101101.00011001.00011000.00000000

Subnet 5

173.25.32.0

10101101.00011001.00100000.00000000

Subnet 6

173.25.40.0

10101101.00011001.00101000.00000000

Subnet 7

173.25.48.0

10101101.00011001.00110000.00000000

Subnet 8

173.25.56.0

10101101.00011001.00111000.00000000

Subnet 9

173.25.64.0

10101101.00011001.01000000.00000000

Subnet 10

173.25.72.0

10101101.00011001.01001000.00000000

Subnet 11

173.25.80.0

10101101.00011001.01010000.00000000

Subnet 12

173.25.88.0

10101101.00011001.01011000.00000000

Subnet 13

173.25.96.0

10101101.00011001.01100000.00000000

 

Custom Subnetting Practice

 

Given the class B address of 172.20.0.0 determine the new subnet mask at the new subnet addresses for 10 subnets. This will subnet a single large network into 10 smaller networks.

 

 

Decimal

Binary

Original network

173.20.0.0

10101100.00010100.00000000.00000000

Original subnet mask

255.255.0.0

11111111.11111111.00000000.00000000

New subnet mask

255.255.240.0

11111111.11111111.11111000.00000000

Subnet 1

173.20.8.0

11111111.11111111.00001000.00000000

Subnet 2

173.20.16.0

11111111.11111111.00010000.00000000

Subnet 3

173.20.24.0

11111111.11111111.00011000.00000000

Subnet 4

173.20.32.0

11111111.11111111.00100000.00000000

Subnet 5

173.20.40.0

11111111.11111111.00101000.00000000

Subnet 6

173.20.48.0

11111111.11111111.00110000.00000000

Subnet 7

173.20.56.0

11111111.11111111.00111000.00000000

Subnet 8

173.20.64.0

11111111.11111111.01000000.00000000

Subnet 9

173.20.72.0

11111111.11111111.01001000.00000000

Subnet 10

173.20.80.0

11111111.11111111.01010000.00000000

 

Subnet Hosts

Hosts are computers or other objects (such as printers) that need IP addresses on a network. Once you’ve determined your network addresses you have to know what IP addresses you can assign to your hosts. In our example above we split our 173.25.0.0 network into 10 separate networks. We know the network Ids, so now we need the IP address range we can use on each network.

 

 

Decimal

IP Address Range

Binary

Original network

173.25.0.0

 

10101101.00011001.00000000.00000000

Original subnet mask

255.255.0.0

 

11111111.11111111.00000000.00000000

New subnet mask

255.255.240.0

 

11111111.11111111.11111000.00000000

(convert the middle octet to binary)

Subnet 1

173.25.0.0

173.25.0.1-173.25.7.254

10101101.00011001.00000000.00000000

See how we did that? We started with adding 1 to the end of the network ID and then took 1 away from the third octet of the starting address for the next subnet. If we convert the 2nd IP address into binary we see it comes out to be 10101101.00011001.00000111.11111110. The IP 173.25.15.255 would result in all 1s on the host ID. That address is the broadcast address for this subnet, so it can’t be assigned to any computers.

See how that works? Pretty nifty, huh?

Subnet 2

173.25.8.0

173.25.8.1-173.25.15.254

10101101.00011001.00001000.00000000

Subnet 3

173.25.16.0

173.25.16.1-173.25.23.254

10101101.00011001.00010000.00000000

You do the rest!

Subnet 4

173.25.24.0

173.25.24.1-173.25.31.254

10101101.00011001.00011000.00000000

Subnet 5

173.25.32.0

173.25.32.1-173.25.39.254

10101101.00011001.00100000.00000000

Subnet 6

173.25.40.0

173.25.40.1-173.25.47.254

10101101.00011001.00101000.00000000

Subnet 7

173.25.48.0

173.25.48.1-173.25.55.254

10101101.00011001.00110000.00000000

Subnet 8

173.25.56.0

173.25.56.1-173.25.63.254

10101101.00011001.00111000.00000000

Subnet 9

173.25.64.0

173.25.64.1-173.25.71.254

10101101.00011001.01000000.00000000

Subnet 10

173.25.72.0

173.25.72.1-173.25.79.254

10101101.00011001.01001000.00000000

Subnet 11

173.25.80.0

173.25.80.1-173.25.87.254

10101101.00011001.01010000.00000000

Subnet 12

173.25.88.0

173.25.88.1-173.25.95.254

10101101.00011001.01011000.00000000

Subnet 13

173.25.96.0

173.25.96.1-173.25.103.254

10101101.00011001.01100000.00000000

 

Finding Valid Hosts

Once you have calculated your network Ids for your subnets you want to find out the valid hosts. For the subnets you found in the custom subnetting practice, find starting IP, ending IP, and the broadcast address for each subnet.

 

 

Decimal

Binary

Original network

173.20.0.0

10101100.00010100.00000000.00000000

Original subnet mask

255.255.0.0

11111111.11111111.00000000.00000000

New subnet mask

 

 

Subnet

Starting IP

Ending IP

Broadcast IP

Subnet 1

173.20.8.1

173.20.15.254

173.20.15.255

Subnet 2

173.20.16.1

173.20.23.254

173.20.23.255

Subnet 3

173.20.24.1

173.20.31.254

173.20.31.255

Subnet 4

173.20.32.1

173.20.39.254

173.20.39.255

Subnet 5

173.20.40.1

173.20.47.254

173.20.47.255

Subnet 6

173.20.48.1

173.20.55.254

173.20.55.255

Subnet 7

173.20.56.1

173.20.63.254

173.20.63.255

Subnet 8

173.20.64.1

173.20.71.254

173.20.71.255

Subnet 9

173.20.72.1

173.20.79.254

173.20.79.255

Subnet 10

173.20.80.1

173.20.87.254

173.20.87.255

 

How do I Know How Many Hosts on a Subnet

You can use your old friend, the 2n-2= formula except in a slightly way.

 

  1. Count the number of host bits (the number of 0s) in the subnet mask. That will be n.
  2. Now plug that into the formula: 2n-2=number of hosts per network.

 

Host Bits

Formula

Usable Hosts

6

26-2

64-2=62

8

28-2

256-2=254

10

 

 

12

 

 

 

You fill in the rest!

 

Supernetting

Supernetting is the opposite of subnetting. In subnetting you take one large network and create smaller ones. In supernetting you take a number of smaller networks and create one (or fewer) large networks. Instead of borrowing bits from the host ID, you borrow bits from the network ID.

 

Why would you do this? Let’s say your company has a large network and purchases or leases two class C IP address ranges. They don’t want two networks, they want only one. They can use supernetting to create one large network out of the two small ones.

 

Another benefit of supernetting is reducing routing complexity. You have to have a router between every subnet on a network. On an old 10 Mbps you might have subnetted into multiple networks to reduce collisions. If you update your hardware to 100 Mbps switches, NICs, and wiring, you can buy fewer routers and combine class C network Ids to create fewer larger networks, thus reducing complexity and saving the company money! Sweet!

 

Example:

 

Decimal

Binary

Original network 1

192.168.10.0

11000000.10101000.00001010.00000000

Original network 2

192.168.11.0

11000000.10101000.00001011.00000000

Original subnet mask

255.255.255.0

11111111.11111111.11111111.00000000

Supernetted network

192.168.10.0

11000000.10101000.00001010.00000000

New subnet mask

255.255.254.0

11111111.11111111.11111110.00000000

First host

192.168.10.1

11000000.10101000.00001010.00000001

Last host

192.168.11.254

11000000.10101000.00001011.11111110

Broadcast

192.168.11.255

11000000.10101000.00001011.11111111

 

Supernetting four Class C networks

 

Decimal

Binary

Original network 1

192.168.76.0

11000000.10101000.01001100.00000000

Original network 2

192.168.77.0

11000000.10101000.01001101.00000000

Original network 3

192.168.78.0

11000000.10101000.01001110.00000000

Original network 4

192.168.79.0

11000000.10101000.01001110.00000000

Original subnet mask

255.255.255.0

11111111.11111111.11111111.00000000

Supernetted network

192.168.76.0

11000000.10101000.01001100.00000000

New subnet mask

255.255.252.0

11111111.11111111.11111100.00000000

First host

192.168.76.1

11000000.10101000.01001100.00000001

Last host

192.168.79.254

11000000.10101000.01001111.11111110

Broadcast

192.168.79.255

11000000.10101000.01001111.11111110

 

Fill in the following table showing supernetting of three networks. Borrow 2 bits from the network ID.

 

Decimal

Binary

Original network 1

192.168.10.0

11000000.10101000.00001010.00000000

Original network 2

192.168.11.0

11000000.10101000.00001011.00000000

Original network 3

192.168.12.0

11000000.10101000.01001110.00000000

Original subnet mask

255.255.255.0

11111111.11111111.11111111.00000000

Supernetted network

192.168.10.0

11000000.10101000.00001010.00000000

New subnet mask

255.255.252.0

11111111.11111111.11111100.00000000

First host

192.168.10.1

11000000.10101000.00001010.00000001

Last host

192.168.12.254

11000000.10101000.00001100.11111110

Broadcast

192.168.12.255

11000000.10101000. 00001100.11111110