Subnetting
Subnet Mask
• Define a range of ip addressess in a subnet
• A subnet mask has 32 bits.
• 11111111.00000000.00000000.00000000 = 255.0.0.0
(/8)
• 11111111.11111111.11111111.11111111=
255.255.255.255 (/32)
• Each "1" in the subnet mask represents a bit that is used
for the network portion, and each "0" represents a bit
that is used for the host portion.
• Subnet masks should have consecutive 1s followed by
consecutive 0s.
Subnet Mask
Example of a valid subnet mask
• 11111111.11111111.11111111.00000000 =
255.255.255.0
• 11111111.11111111.11111100.00000000 =
255.255.252.0
Example of invalid subnet mask
• 11111111.11011111.11111111.00000000
Question
Which of the following is a valid subnet mask?
Question
Which of the following is a valid subnet mask?
Subnetting examples
• Lets calculate the number of network and hosts bits in
200.100.50.0/18.
• First lets convert CIDR to Binary.So /18 becomes:
• 11111111.11111111.11000000.00000000
Network Hosts Bits(32-
Bits(18) 18=14)
• Now lets convert CIDR(Classless inter-domain routing)
/18 to subnet mask:
Subnetting examples
• 11111111.11111111.11000000.00000000 (/18)
Subnetting examples
11111111
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
1 1 1 1 1 1 1 1
128+64+32+16+8+4+2+1
= 255
Subnetting examples
11000000
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
1 1 0 0 0 0 0 0
128+64
= 192
Subnetting examples
00000000
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
0 0 0 0 0 0 0 0
=0
Subnetting examples
• Thus 11111111.11111111.11000000.00000000 (/18)
becomes:
• 255.255.192.0
How to calculate number of hosts?
• 11111111.11111111.11000000.00000000 (/18)
• Number of hosts bits =32-(network bits)
• = 32 - 18
• = 14
• Thus number of hosts becomes
• = 2n (where n = no of hosts bits)
• = 214
• =16384
How to calculate number of valid
hosts?
• Since we know every network has one network IP
address and one broadcast IP address, which
cannot be assigned to end devices.
• Thus number of valid hosts becomes:
• No of hosts – 2
• = 214 -2
• = 16384 -2
• = 16382
Question 1
• How many hosts bits are required to represent a subnet
containing 550 valid hosts ?
• 2n >= Number of valid Hosts + 2 (where n is the
number of host bits).
• or, 2n >= 550+2
• or, 2n >= 552
• or, 29 >= 552
• or, 512 >=552
• or, 210 >=552
• or, 1024 >= 552
• Thus 10 hosts bits are required to represent a subnet
containing 550 valid hosts
Question 1
• Lets also calculate subnetmask and also CIDR too.
• Since Number of Hosts bits was 10.
• Thus number of network bits becomes
• =32-10
• =22
• Thus the CIDR becomes /22 and subnet mask becomes:
• 255.255.252.0
Another way of calculation subnet
mask
• Suppose you have to convert /22 to subnet mask.
• We know that first 2 octets are full.
• So for third octet:
• = 24-2
• = 255 – (20 + 21)
• = 255 - (1+2)
• = 255 – 3
• = 252
• Thus subnet mask of /22 becomes 255.255.252.0
Question 2
• How many hosts bits are required to represent a subnet
containing 2048 valid hosts ? Also calculate subnetmask
and CIDR too.
• Ans:
Calculate Number of Hosts
• A subnet mask defines the range of IP addresses in a
subnet.
• Ip Address: 192.168.0.0/29
• No of hosts = (32-29) = 3 = 23 = 8 Ip address
• What if subnet mask is used:
• 192.168.0.0 255.255.255.248
Calculate Number of Host
• A subnet mask defines the range of IP addresses in a
subnet.
• Ip Address: 192.168.0.0/29
• No of hosts = (32-29) = 3 = 23 = 8 Ip address
• What if subnet mask is used instead of CIDR:
• 192.168.0.0 255.255.255.248
Subnet Range
• A subnet mask defines the range of IP addresses in a
subnet.
• Ip Address: 172.16.0.0/21
• No of hosts = (32-21) = 11 = 211 = 2048 Ip address
• What if subnet mask is used:
• 172.16.0.0 255.255.248.0
Subnet Ranges
• The Subnet Size is just a short way of saying “the
number of Ip addresses in a subnet”.
• For example 192.168.0.123/26
• No of hosts = (32-26) =6 = 26 = 64 ip address
• So does it mean the subnet ranges from
192.168.0.123 – 192.168.0.186?
Subnetting Class C ip address
So how do we subnet 192.168.0.123/26 correctly ?
• No of hosts = 64
• No of hosts = size of subnet
• First Host = Network + 1
• Last Host = Broadcast -1
Network 192.168.0.0
First Host
Last Host
Broadcast
Subnetting Class C ip address
Network 192.168.0.0
First Host
Last Host
Broadcast
Subnetting Class C ip address
So how do we subnet 192.168.0.123/26 correctly ?
• No of hosts = 64
• No of hosts = size of subnet
• First Host = Network + 1
• Last Host = Broadcast -1
Network 192.168.0.0 192.168.0.64 192.168.0.128 192.168.0.192
First Host 192.168.0.1 192.168.0.65 192.168.0.129 192.168.0.193
Last Host 192.168.0.62 192.168.0.126 192.168.0.190 192.168.0.254
Broadcast 192.168.0.63 192.168.0.127 192.168.0.191 192.168.0.255
Subnetting Class B Ip address
So how do we subnet 172.16.0.200/19 ?
• No of hosts
• = 8192
• No of valid hosts
• = 8192-2 = 8190
Network 172.16.0.0
First Host
Last Host
Broadcast
/19
• First convert /19 to binary
• 11111111.11111111.11100000.00000000
• Thus in order to know the broadcast address
• In third octate (11100000)
No of hosts bit = 5
• = 20+21+22+23+24
• = 31
• =172.16.31.255
/19
• Else,
• Simply Divide the subnet size by 256.
• So for /19
• No of hosts
• = 213 = 8192
• = So now,
• 8192/256
• = 32
• Thus Broadcast ip = 32-1 = 31.255
Subnetting Class B Ip address
So how do we subnet 172.16.0.200/19 ?
• No of hosts
• = 8192
• No of valid hosts
• = 8192-2 = 8190
Network 172.16.0.0
First Host
Last Host
Broadcast
Subnetting Class B Ip address
So how do we subnet 172.16.0.200/19 ?
• No of hosts
• = 8192
• Thus the size of network is
• =8192/256
• =32
Network 172.16.0.0 172.16.32.0
First Host
Last Host
Broadcast
Subnetting Class B Ip address
So how do we subnet 172.16.0.200/19 ?
• No of hosts
• = 8192
• Thus the size of network is
• =8192/256
• =32
Network 172.16.0.0 172.16.32.0 172.16.64.0 172.16.96.0
First Host
Last Host
Broadcast
Subnetting Class B Ip address
Network 172.16.0.0 172.16.32.0 172.16.64.0 172.16.96.0
First Host
Last Host
Broadcast
Subnetting Class B Ip address
So how do we subnet 172.16.0.200/19 ?
• No of hosts
• = 8192
• Thus the size of network is
• =8192/256
• =32
Network 172.16.0.0 172.16.32.0 172.16.64.0 172.16.96.0
First Host 172.16.0.1 172.16.32.1 172.16.64.1 172.16.96.1
Last Host 172.16.31.254 172.16.63.254 172.16.95.254 172.16.127.254
Broadcast 172.16.31.255 172.16.63.255 172.16.95.255 172.16.127.255
Subnetting Class A Ip address
So how do we subnet 14.0.0.200/10 ?
No of hosts
= 4194304
Thus the size of network is
=4194304/(256*256)
=64
Network 14.0.0.0 14.64.0.0 14.128.0.0 14.192.0.0
First Host 14.0.0.1 14.64.0.1 14.128.0.1 14.192.0.1
Last Host 14.63.255.254 15.127.255.254 14.191.255.254 14.255.255.254
Broadcast 14.63.255.255 14.127.255.255 14.191.255.255 14.255.255.255
Task
• Schoolworkspro