Upload
doanhuong
View
215
Download
1
Embed Size (px)
Citation preview
The Internet Assigned Numbers Authority (IANA) has reserved the
following three blocks of the IP address space for private
internets:
10.0.0.0 - 10.255.255.255 (10/8 prefix)
172.16.0.0 - 172.31.255.255 (172.16/12 prefix)
192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
We will refer to
the first block as "24-bit block",
the second as "20-bit block", and to
the third as "16-bit" block.
Note that (in pre-CIDR notation)
the first block is nothing but a single class A network number,
the second is a set of 16 contiguous class B network numbers,
and the third is a set of 256 contiguous class C network numbers.
Subnetting
Example A campus network
Here each of the ethernets has his own router
connected to the main router
How does it work
• When a packet comes into the main router, how
does this know which subnet (Ethernet) to give it
to?
• Having a host table with 65K entries each with the
responsable router is impractical
• A better way is that of devoting a part of the host
address to the specification of the router address
Fixed Length Mask Subnetting
In practice some bits are taken away from the host number to
create a subnet number
This adds another level of hierarchy to the IP addressing structure.
Instead of the classful two-level hierarchy, subnetting supports a three-
level hierarchy.
Subnet Mask
To implement subnetting the main router needs a subnet mask that indicates
the split between the network+subnetwork number and host: the subnet mask
tells the net router where the host addresses starts. The bits of the subnet
mask are set to 1 if the system examining the address should treat the
corresponding bit in the IP address as part of the extended-network- prefix.
The bits in the mask are set to 0 if the system should treat the bit as part of
the host-number.
Extended-Network-Prefix LengthThe standards describing modern routing protocols often refer to
the extended-network-prefix- length rather than the subnet mask.
The prefix length is equal to the number of contiguous
one-bits in the traditional subnet mask.
However, it is important to note that modern routing protocols
still carry the subnet mask. There are no Internet standard routing
protocols that have a one-byte field in their header that contains
the number of bits in the extended-network prefix. Rather,
each routing protocol is still required to carry the complete four-octet subnet mask.
How does it work?
In order to route an incoming packet
the main router uses the mask by performing
a logical AND operation, so as to extract the
network address from the overall address, and hands
the packet to the corresponding router.
Address: 11000000 10101000 00010010 10110111
Subnet Mask: 11111111 11111111 11111111 11000000
AND -------- -------- -------- --------
Network ID: 11000000 10101000 00010010 10000000
In the last column of the above example
we have a class C address with a mask of length 26
which tells us that the host portion of the address
10110111 must be split into
the subnet prefix 10
and the host address 110111
How it works without subnetting
• Each router has a table listing
some number of (network, 0) IP addresses and
some number of (this-network, host) IP addresses:
associated with each table is the network interface
to use to reach the destination.The first table is for distant
networks, the second for local hosts.
• When an IP packet arrives its destination address is looked up
in the routing table: if it is for a distant network it is
forwarded to the router indicated in the table; if it is for a
local host (e.g. on the touter LAN) it is sent directly to dht
destination.
How it works with subnetting• When subnetting is introduced the routing tables are
changed, adding entries of the form
(this-network, subnet, 0) and
(this-network, this-subnet, host)
• The first is used to reach other subnets,
the second to reach the hosts of the local subnet.
• Notice that in this way the router does not have to know
the details about the hosts on other subnets: the router will
- take the IP address
- perform an AND with the subnet mask
getting rid of the host number
- look up the resulting subnet number in the routing table.
BenefitsThe size of the global Internet routing table does not grow
because the site administrator does not need to obtain additional
address space and the routing advertisements for
all of the subnets are combined into a single routing table entry.
The local administrator has the flexibility to deploy
additional subnets without obtaining a new network
number from the Internet.
Route flapping (i.e., the rapid changing of routes)
within the private network does not affect the
Internet routing table since Internet routers
do not know about the reachability of the individual
subnets - they just know about the reachability
of the parent network number.
Subnet Design Considerations
The deployment of an addressing plan requires careful thought on the part of the network
administrator. There are four key questions that must be answered before any design
should be undertaken:
1) How many total subnets does the organization need today?
2) How many total subnets will the organization need in the future?
3) How many hosts are there on the organization's largest subnet today?
4) How many hosts will there be on the organization's largest subnet in the future?
All Zero and all one hosts
Recall that according to Internet practices,
the host-number field of an IP address
cannot contain all 0-bits or all 1-bits:
- the all-0s host-number identifies the base network
(or subnetwork) number,
-the all-1s host-number represents the broadcast address
for the network (or subnetwork).
In practice with n bits one will be able to address 2^n-2 hosts
To subnet a network, extend the natural mask using some of the bits
from the host ID portion of the address to create a subnetwork ID.
For example, given a Class C network of 204.15.5.0 which has a
natural mask of 255.255.255.0, you can create subnets in this manner:
204.15.5.0 - 11001100.00001111.00000101.00000000
255.255.255.224 - 11111111.11111111.11111111.11100000
--------------------------|sub|----
By extending the mask to be 255.255.255.224, you have taken
three bits (indicated by "sub") from the original host portion
of the address and used them to make subnets. With these three bits,
it is possible to create eight subnets.
With the remaining five host ID bits, each subnet can have
up to 32 host addresses, 30 of which can actually
be assigned to a device since host ids of all zeros or all ones
are not allowed. So, with this in mind, these subnets have been created.
204.15.5.0 255.255.255.224 host address range 1 to 30
204.15.5.32 255.255.255.224 host address range 33 to 62
204.15.5.64 255.255.255.224 host address range 65 to 94
204.15.5.96 255.255.255.224 host address range 97 to 126
204.15.5.128 255.255.255.224 host address range 129 to 158
204.15.5.160 255.255.255.224 host address range 161 to 190
204.15.5.192 255.255.255.224 host address range 193 to 222
204.15.5.224 255.255.255.224 host address range 225 to 254
How to subnet a network
Three bits are reserved for the subnet addresses
Five bits are reserved for the host addresses
This means that there is going to be room
for 2^3 = 8 subnets each with at most
2^5-2 = 30 hosts
Example
Subnetting a class C network
More subnets => less hosts
This brings up an interesting point.
The more host bits you use for a subnet mask,
the more subnets you have available.
However, the more subnets available,
the less host addresses available per subnet.
For example, a Class C network of 204.17.5.0
and a mask of 255.255.255.224 (/27) allows you
to have eight subnets, each with 32 host addresses
(30 of which could be assigned to devices).
If you use a mask of 255.255.255.240 (/28),
the break down is:
204.15.5.0 - 11001100.00001111.00000101.00000000
255.255.255.240 - 11111111.11111111.11111111.11110000
--------------------------|sub |---
Since you now have four bits to make subnets with,
you only have four bits left for host addresses.
So in this case you can have up to 16 subnets,
each of which can have up to 16 host addresses
(14 of which can be assigned to devices).
Class C Host/Subnet Table
Class C Subnet Effective Effective Number of Subnet
Bits Mask Subnets Hosts Mask Bits
------- --------------- --------- --------- --------------
1 255.255.255.128 2 126 /25
2 255.255.255.192 4 62 /26
3 255.255.255.224 8 30 /27
4 255.255.255.240 16 14 /28
5 255.255.255.248 32 6 /29
6 255.255.255.252 64 2 /30
7 255.255.255.254 128 2* /31
Notice that an exception to the 2^n-2 rule is 31-bit prefixes,
marked with an asterisk ( * ).
Subnetting a Class B network
Take a look at how a Class B network might be subnetted.
If you have network 172.16.0.0 ,then you know that its natural
mask is 255.255.0.0 or 172.16.0.0/16. Extending the mask
to anything beyond 255.255.0.0 means you are subnetting.
You can quickly see that you have the ability to create
a lot more subnets than with the Class C network.
If you use a mask of 255.255.248.0 (/21), how many subnets
and hosts per subnet does this allow for?
172.16.0.0 - 10101100.00010000.00000000.00000000
255.255.248.0 - 11111111.11111111.11111000.00000000
-----------------| sub |-----------
You are using five bits from the original host bits for subnets.
This will allow you to have 32 subnets (25). After using
the five bits for subnetting, you are left with 11 bits
for host addresses. This will allow each subnet
so have 2048 host addresses (211), 2046 of which
could be assigned to devices.
Example
Subnetting a class B network
Nine bits are reserved for the subnet addresses
Seven bits are reserved for the host addresses
This means that there is going to be room
for 2^9 = 512 subnets each with at most
2^7-2 = 126 hosts
Class B Host/Subnet Table
Class B Subnet Effective Effective Number of Subnet
Bits Mask Subnets Hosts Mask Bits
------- --------------- --------- --------- -------------
1 255.255.128.0 2 32766 /17
2 255.255.192.0 4 16382 /18
3 255.255.224.0 8 8190 /19
4 255.255.240.0 16 4094 /20
5 255.255.248.0 32 2046 /21
6 255.255.252.0 64 1022 /22
7 255.255.254.0 128 510 /23
8 255.255.255.0 256 254 /24
9 255.255.255.128 512 126 /25
10 255.255.255.192 1024 62 /26
11 255.255.255.224 2048 30 /27
12 255.255.255.240 4096 14 /28
13 255.255.255.248 8192 6 /29
14 255.255.255.252 16384 2 /30
15 255.255.255.254 32768 2* /31
Class A Host/Subnet TableClass A
Number of
Bits Borrowed Subnet Effective Number of Number of Subnet
from Host Portion Mask Subnets Hosts/Subnet Mask Bits
------- --------------- --------- ------------- -------------
1 255.128.0.0 2 8388606 /9
2 255.192.0.0 4 4194302 /10
3 255.224.0.0 8 2097150 /11
4 255.240.0.0 16 1048574 /12
5 255.248.0.0 32 524286 /13
6 255.252.0.0 64 262142 /14
7 255.254.0.0 128 131070 /15
8 255.255.0.0 256 65534 /16
9 255.255.128.0 512 32766 /17
10 255.255.192.0 1024 16382 /18
11 255.255.224.0 2048 8190 /19
12 255.255.240.0 4096 4094 /20
13 255.255.248.0 8192 2046 /21
14 255.255.252.0 16384 1022 /22
15 255.255.254.0 32768 510 /23
16 255.255.255.0 65536 254 /24
17 255.255.255.128 131072 126 /25
18 255.255.255.192 262144 62 /26
19 255.255.255.224 524288 30 /27
20 255.255.255.240 1048576 14 /28
21 255.255.255.248 2097152 6 /29
22 255.255.255.252 4194304 2 /30
23 255.255.255.254 8388608 2* /31
Subnetting Example
The first entry in the Class A table (/10 subnet mask) borrows two bits (the leftmost bits)
from the host portion of the network for subnetting, then with two bits you have
four (22) combinations, 00, 01, 10, and 11. Each of these will represent a subnet.
Binary Notation Decimal Notation
-------------------------------------------------- -----------------
xxxx xxxx. 0000 0000.0000 0000.0000 0000/10 ------> X.0.0.0/10
xxxx xxxx. 0100 0000.0000 0000.0000 0000/10 ------> X.64.0.0/10
xxxx xxxx. 1000 0000.0000 0000.0000 0000/10 ------> X.128.0.0/10
xxxx xxxx. 1100 0000.0000 0000.0000 0000/10 ------> X.192.0.0/10
Note: The subnet zero and all-ones subnet are included in the effective number of subnets
as shown in the third column.