06-Subnetting File

Download Report

Transcript 06-Subnetting File

Subnetting
• Subnetting is not in the CIS221-3 Syllabus
• It was covered in CIS110 last year
• We are revising it because:
– We need to study supernetting
– The technique is similar to subnetting
– Some students find it difficult
16/11/10
06-Subnetting
1
Revision of Classful IP Addressing
© Tanenbaum, Prentice Hall International
16/11/10
06-Subnetting
2
Revision of Classful IP Addressing
Class Class ID 1st Octet Networks Hosts
A
01
1-126
01111111
127
B
10
128-191
16,382
65,534
Medium Networks
C
110
192-223
2,097,152
254
Small Networks
D
1110
224-239
Multicast
E
1111
240-255
Experimental
16/11/10
126
Purpose
16,777,214 Large Networks
Loopback
06-Subnetting
3
Revision of Classful IP Addressing
• Note that for every range of network Ids and host
IDs, two cannot be used.
• Network Ids of all 0s means this network
• Network Ids of all 1s means all networks
• Host Ids of all 0s are used to define an IP address for
the network itself
• Host Ids of all 1s are used for a broadcast address for
all hosts on the network
• Therefore for both host and network Ids which are N
bits long, the number of valid addresses is 2N – 2
16/11/10
06-Subnetting
4
Net Masks
Address
Class
Net Mask
255.0.0.0
Class A
11111111000000000000000000000000
255.255.0.0
Class B
11111111111111110000000000000000
255.255.255.0
Class C
11111111111111111111111100000000
16/11/10
06-Subnetting
5
Classful Routing
• When a router receives a packet, it examines the destination
address in the IP header
• It checks the first byte of the address and determines the address
class and the net mask for this class.
• It then applies does a bitwise AND between the destination
address and the net mask to determine the destination network
address
• It then looks up the destination network address in its routing
table and finds the IP address of the router it should forward the
packet to and which interface this address can be reached by
• Finally, it routes the packet
16/11/10
06-Subnetting
6
Example of Classful Routing
• Suppose the destination address is 164.36.4.6
• The first byte is between 128 and 191, so it is a Class B
address
• The net mask for a Class B address is 255.255.0.0
• Bitwise AND the destination address and the default net mask
to give 164.36.0.0 as the destination network address
• Look up 164.36.0.0 in the routing table and obtain the IP
address of the next router and the interface by which it can be
reached (say 132.15.234.1 by serial 0)
• Route the packet with destination address 164.36.4.6 out of
the serial 0 interface.
16/11/10
06-Subnetting
7
Revision of Subnetting
• With subnetting the host ID part of the IP address is
further sub-divided into a subnetwork ID and a host ID
• This allows organisations to structure the Class A, B or
C addresses into a further hierarchy where each
subnetwork can be identified by a different subnetwork
address
• Only routers within the subnetwork need to have
entries for the subnetwork addresses and knowledge of
the subnet mask used
• All other routers on the Internet just have one entry for
the network address, thus reducing routing table size
16/11/10
06-Subnetting
8
Example 1: 204.33.180.0 – Class C
• We have a Class C network address (with an 8-bit
host ID) given above and we want to use it to create
six subnetworks each having up to 30 hosts
• We need 3 bits to define the subnet and 5 to define
the hosts to give 23 – 2 = 6 subnetwork addresses
each with 25 – 2 = 30 hosts
• With subnetting there is always just one byte that we
need to work with. It is the byte in which the
boundary between the subnet ID and the host ID is
found. This is known as the interesting byte. It is
the last byte in the network address that is not all 0s
or the last byte in the subnet mask that is not all 1s
16/11/10
06-Subnetting
9
Example 1: 204.33.180.0 – Class C
• In the case of a Class C address, the
interesting byte is the last byte.
• The subnet mask will be the all 1s in the
first 3 bytes and the final byte will be
111|000002 = 22410
• The ‘|’ represents the boundary between the
subnet ID and the host ID
• Subnet mask is therefore 255.255.255.224
16/11/10
06-Subnetting
10
Example 1: 204.33.180.0 – Class C
• So, if we are given a host address
204.33.180.106 we need to bitwise AND it
with the subnet mask 255.255.255.224 to
get the address of its subnet.
• Again we only need to look at the
interesting (last) byte:
• 22410 = 111|000002
• 10610 = 011|010102
• ANDed 011|000002 = 9610
16/11/10
06-Subnetting
11
Example 1: 204.33.180.96 – Class C
• So the subnetwork address is:
204.33.180.96
9610 = 011|000002
• The first valid host address is:
204.33.180.97
9710 = 011|000012
• The broadcast address is:
204.33.180.127
12710 = 011|111112
• The last valid host address is:
204.33.180.126
16/11/10
12610 = 011|111102
06-Subnetting
12
Example 2: 132.40.17.200 – Class B
• Suppose the subnet mask is 255.255.255.128
• The interesting byte is the last byte in the
subnet mask which is not all 1s (i.e. the last
byte)
12810
=
1|00000002
20010
=
1|10010002
ANDed
1|00000002 =
12810
There will be 29- 2 valid subnetwork addresses
and 27 - 2 valid host addresses
16/11/10
06-Subnetting
13
Example 2: 132.40.17.200 – Class B
• So the subnetwork address is:
132.40.17.128
12810 = 1|00000002
• The first valid host address is:
132.40.17.129
12910 = 1|00000012
• The broadcast address is:
132.40.17.255
25510 = 1|11111112
• The last valid host address is:
132.40.17.254
16/11/10
25410 = 1|11111102
06-Subnetting
14
Example 3: 120.19.51.6 – Class A
• Suppose the subnet mask is 255.252.0.0
• The interesting byte is the last byte in the
subnet mask which is not all 1s (i.e. the 2nd
byte)
25210
=
111111|002
1910
=
000100|112
ANDed
000100|002 =
1610
There will be 26- 2 valid subnetwork addresses
and 218- 2 valid host addresses
16/11/10
06-Subnetting
15
Example 3: 120.19.51.6 – Class A
• So the subnetwork address is:
120.16.0.0
1610 = 000100|002
• The first valid host address is:
120.16.0.1
• The broadcast address is:
120.19.255.255
1910 = 000100|112
• The last valid host address is:
120.19.255.254
16/11/10
06-Subnetting
16
Exercise 1: 86.20.38.0 – Class A
• How many valid subnet addresses and host
addresses are supported by the subnetwork
address 86.20.38.0 with subnet mask
255.255.224.0?
• Find the first valid host address, last valid
host address and broadcast address for the
subnetwork
16/11/10
06-Subnetting
17
Exercise 1: 86.20.38.0 – Class A
• Interesting byte is the 3rd byte
22410
=
111|000002
3810
=
001|001102
ANDed
001|000002 =
3210
There will be 211- 2 valid subnetwork addresses
and 213- 2 valid host addresses
16/11/10
06-Subnetting
18
Exercise 1: 86.20.38.0 – Class A
• So the subnetwork address is:
86.20.32.0
3210 = 001|000002
• The first valid host address is:
86.20.32.1
• The broadcast address is:
86.20.63.255
6310 = 001|111112
• The last valid host address is:
86.20.63.254
16/11/10
06-Subnetting
19
Exercise 2: 160.16.18.99 - Class B
• How many valid host address belong to the
same subnet as 160.16.18.99 if the subnet
mask is 255.255.255.192?
• What are the first and last valid host
addresses in this subnet?
16/11/10
06-Subnetting
20
Exercise 2: 160.16.18.99 - Class B
• Interesting byte is the last byte
19210
=
11|0000002
9910
=
01|1000112
ANDed
01|0000002 =
6410
There will be 210- 2 valid subnetwork addresses
and 26- 2 valid host addresses
16/11/10
06-Subnetting
21
Exercise 2: 160.16.18.99 - Class B
• So the subnetwork address is:
160.16.18.64
6410 = 01|0000002
• The first valid host address is:
160.16.18.65
6510 = 01|0000012
• The broadcast address is:
160.16.18.127
12710 = 01|1111112
• The last valid host address is:
160.16.18.126
16/11/10
12610 = 01|1111102
06-Subnetting
22
Exercise 3: 193.25.18.0 – Class C
• A customer has been allocated the Class C
network address 193.25.18.0 and wishes to
create up to 30 subnets each of which
having a maximum of 6 hosts.
• What subnet mask should he use?
• What will be the subnet address of the first
subnet?
• What will be the broadcast address of this
subnet?
16/11/10
06-Subnetting
23
Exercise 3: 193.25.18.0 – Class C
• For Class C addresses the interesting byte is the
last byte
• 30 subnets require 25 bits
• 6 hosts requires 23 bits
• Last byte of subnet mask is 11111|0002 = 24810
• Full Subnet Mask is 255.255.255.248
• First theoretical subnetwork address is the network
address given (193.25.18.0), but this would have a
subnetwork address of all 0s 00000|0002, which is
used to identify the subnetwork and this
subnetwork is not normally used for hosts
16/11/10
06-Subnetting
24
Exercise 3: 193.25.18.0 – Class C
• So the first subnetwork address is:
193.25.18.8
810 = 00001|0002
• The first valid host address in first subnet is:
193.25.18.9
910 = 00001|0012
• The broadcast address of first subnet is:
193.25.18.15
1510 = 000011112
• The last valid host address is:
193.25.18.14
16/11/10
1410 = 000011102
06-Subnetting
25