IPv4 subnetting
Download
Report
Transcript IPv4 subnetting
IP – Subnetting and CIDR
Logical sub-grouping of nodes
A single class C IP network address 193.75.45.0 (say) is to be used for several
physical networks; Subnet mask: 255.255.255.0
One seemingly plausible way might simply be to divide the addresses:
Lan X: hosts 1 – 30,
Lan Y: hosts 40 – 70,
Lan Z: hosts 100 – 130
However, this simple allocation does not separate the nodes into broadcast domains
(it does not divide the numbers on ‘binary boundaries’ in the number ranges)
Thus routers cannot use the network portion to make forwarding decisions within the
network. → need a structured approach to subnetting
WAN link
to Internet
LAN X
LAN Z
LAN Y
IP subnetting
Allow arbitrary complexity of internetworked LANs
within organization
To reduce the size of a broadcast domain
To facilitate routing between networks within an
autonomous system
Insulate overall internet from growth of network numbers
and routing complexity
Site looks to rest of internet like single network
Each LAN is assigned subnet number
Host portion of address partitioned into subnet number
and host number
Local routers route within the subnetted network
Subnet mask indicates which bits are subnet number and
which are host number
Borrowing bits for the subnet
32-bit IP address
Network portion
Subnet mask
Subnet bits
Host portion
1111111 ….…. 111111 11………...11 00 ….……..00
We extend the network address by a few bits
by borrowing from the host part
Subnet bits are the most-significant of the host
bits
Subnet bits appear as ‘1’ s in the subnet mask
At least 2 bits must be borrowed
The host portion must contain at least 2 bits
Another example
Assigned network address – class C, 192.228.17.0
Borrow 3 bits for subnetting:
see next
Subnets: 1 to 6, up to 30 hosts in each.
slide
001 00000 (32, hosts 33 to 62, 63 is broadcast)
(X)
010 00000 (64, hosts 65 to 94, 95 is broadcast)
(Y)
011 00000 (96, hosts 97 to 126, 127 broadcast)
(Z)
100 00000 …………………..
101 00000 ……………………
110 00000 (192: hosts 193-222, 223 is broadcast)
Class C subnetting Statistics
256
Total
number
of host
addresses
180
128
196
180
124
0
Subnet bits 2
124
3
4
5
6
Subnetting reduces the number of available
addresses
IP addressing: CIDR
Classful addressing:
inefficient use of address space, address space exhaustion
e.g., class B net allocated enough addresses for 65K hosts, even if
only 2K hosts in that network
CIDR: Classless InterDomain Routing
network portion of address of arbitrary length
address format: a.b.c.d/x, where x is the number of bits in network
portion of address
network
part
host
part
11001000 00010111 00010000 00000000
200.23.16.0/23
Supernetting CIDR
Routers use the most specific (longest) match for forwarding
packets.
A routing table entry can represent an aggregation of
networks that exist in the forward path that don't need to be
specified on that particular gateway:
B
A
B
131.65.128.0/18
A
C
Router X
Router Y
131.65.192.0/18
Router X: 131.65.0.0/16 class-B (aggregation)
Router Y will have separate entries for the two.
Hierarchical addressing: route aggregation (a class C example)
The 3rd byte of network address holds two-levels of
address data (part of the supernet address – same for
each organisation, and each organisation’s specific address
extension bits - shown RED:
16 is 0001 0000, 18 is 0001 0010, 20 is 0001 0100,
24 is 0001 1000, 28 is 0001 1100, 30 is 0001 1110
Organization 1
200.23.17.0/24
Organization 2
200.23.18.0/24
Organization 3
200.23.20.0/24
Organization 6
.
.
.
.
.
.
Fly-By-Night-ISP
“Send me anything
with addresses
beginning
200.23.16.0/20”
Internet
200.23.30.0/24
ISPs-R-Us
“Send me anything
with addresses
beginning
199.31.0.0/16”
More specific route preferred
Where there are multiple address matches, the more-specific match is chosen.
This allows different routers to use different size masks (with apparent
addressing overlap - but in fact choosing the most-specific match ensures
correctness in all cases).
Destination add: 200.23.18.45 Matches 200.23.16.0/20 AND 200.23.18.0/24
The /24 is more specific and is chosen.
Organization 1
200.23.17.0/24
Organization 3
200.23.20.0/24
Organization 6
.
.
.
.
.
.
Fly-By-Night-ISP
“Send me anything
with addresses
beginning
200.23.16.0/20”
Internet
200.23.30.0/24
ISPs-R-Us
Organization 2
200.23.18.0/24
“Send me anything
with addresses
beginning 199.31.0.0/16
or 200.23.18.0/24”
Subnetting problems– a worked example
You have a class C network address 202.34.92.0
You need to create 8 subnetworks containing up to 12 hosts in each.
What is the address of the second usable host in the third usable subnet?
1. How many bits to borrow?
4 bits would allow up to 14 subnetworks
this would leave 4 host bits, allowing up to 14 hosts per subnet.
Subnet mask will be 11111111.11111111.11111111.11110000
2. Identify the values of the subnet bits, and host bits
128, 64, 32, 16, 8, 4, 2, 1
• The first usable subnet would contribute the value 16
• The second usable subnet would contribute the value 32
• The third usable subnet would contribute 48 (16 + 32)
• The first usable host would contribute the value 1
• The second usable host would contribute the value 2
The second usable address in the third usable subnet would be
202.34.92.50 (48 + 2)
Subnetting examples
1. What is the subnet mask for a class A network in which four
bits have been used for subnetting ?
2. What is the subnet mask for a class B network in which
seven bits have been used for subnetting ?
3. How many usable subnets are created if ten bits are
borrowed using a class B address ?
4. Refer to the subnets created in Q3. How many usable host
addresses are available each subnet ?
5. How many usable subnets are created if seven bits are
borrowed using a class B address ?
6. Refer to the subnets created in Q5. How many usable host
addresses are available in each subnet ?
More examples
7. Five bits are used for subnetting with 201.45.67.0
In which usable subnet (i.e. 1st, 2nd etc) is host
201.45.67.25?
8. Six bits are used for subnetting 201.45.67.0
In which usable subnet (i.e. 1st, 2nd etc) is host
201.45.67.26?
9. Ten bits are used for subnetting with 131.84.0.0
In which usable subnet (i.e. 1st, 2nd etc) is host
131.84.2.67?
10. Seven bits are used for subnetting: 131.84.0.0
In which usable subnet (i.e. 1st, 2nd etc) is host
131.84.7.132 ?