Transcript addressing

addressing
➢ Introduction
➢ ‘Classfull’
➢ ‘Subnetting’
➢ ‘VLSM’
➢ ‘CIDR’
1
addressing
• An IP address provides a hierarchical structure to
separate networks
• Consider the following address as an example:
– 158.80.164.3
– An IP address is separated into four octets
– Each octet is 8 bits long
– resulting in a 32-bit IP address
• A computer understands an IP address in its binary form
• First Octet Second Octet Third Octet Fourth Octet
10011110
.01010000
.10100100
.00000011
2
• Part of the above IP address identifies the network.
• The other part of the address identifies the host.
• A net mask helps make this distinction.
• Consider the following
– 158.80.164.3
255.255.0.0
– The above IP address has a net mask of 255.255.0.0.
• The net mask follows two rules:
– If a binary bit is set to a 1 (or on) in a net mask, the corresponding bit in the
address identifies the network.
– If a binary bit is set to a 0 (or off) in a net mask, the corresponding bit in the
address identifies the host.
3
Question?
• What is the usefulness of a net mask ?
– (A) Identifying the net associated to an IP
address
– B) Increasing the addressing space
– (C) Hiding the network address
4
Question?
• @IP 192.168.1.1 and Netmask 255.255.255.0,
@Net
(A) 192.168.1.0
(B) 192.168.0.1
(C) 192.0.1.1
(D) 0.168.1.1
5
addressing
•
•
•
•
Looking at 158.80.164.3 and mask 255.255.0.0 in binary
Address: 10011110.01010000.10100100.00000011
net Mask: 11111111.11111111.00000000.00000000
The first 16 bits of the net mask are set to 1. Thus, the
first 16 bits of the address (158.80) identify the network.
• The last 16 bits of the net mask are set to 0. Thus, the last 16
bits of the address (164.3) identify the unique host on that
network.
• Hosts on the same logical network will have identical
network addresses, and can communicate freely.
• For example, the following two hosts are on the same network:
– Host A: 158.80.164.100
255.255.0.0
– Host B: 158.80.164.101
255.255.0.0
6
addressing
• Both share the same network address (158.80), which is
determined by the 255.255.0.0 subnet mask.
• Hosts that are on different networks cannot communicate
without an intermediating device. For example:
– Host A: 158.80.164.100
– Host B: 158.85.164.101
255.255.0.0
255.255.0.0
– The net mask has remained the same, but the network
addresses are now different (158.80 and 158.85
respectively).
– Thus, the two hosts are not on the same network, and
cannot communicate without a router between them.
– Routing is the process of sending packets from one
network to another.
7
addressing
Are these hosts on the same network?
• Host A: 158.80.1.1
• Host B: 158.79.1.1
255.248.0.0
255.248.0.0
8
addressing
Are these hosts on the same network?
• Host A: 158.80.1.1
• Host B: 158.79.1.1
255.248.0.0
255.248.0.0
Host A Address: 10011110.01010000.00000001.00000001
Host B Address: 10011110.01001111.00000001.00000001
Subnet Mask: 11111111.11111000.00000000.00000000
9
Rmq
• We can identify the number of binary bits set to a 1 (or
on) in a netmask, preceded by a slash.
• Consider the following netmask: 255.255.255.240
– Looking at the above net mask in binary:
11111111.11111111.11111111.11110000
– The first 28 bits of the above net mask are set to 1.
– We can represent : /28
• Consider this next example: 192.168.1.1
255.255.255.0
• The above address/netmask can be represented as follows:
192.168.1.1 /24
10
addressing
Classfull
11
IP address Classes
• The IPv4 address space has been structured into several classes.
• The value of the first octet of an address determines the class of
the network:
Class
First Octet Range
Default Subnet Mask
ClassA
1 - 127
255.0.0.0
Class B
128 - 191
255.255.0.0
Class C
192 - 223
255.255.255.0
12
IP address Classes
•
•
•
•
Class A networks range from 1 to 127.
The default net mask is 255.0.0.0;
thus, by default, the first octet defines the network,
and last three octets define the host.
•
N°of network: from 1 to 126 (0 and 127 are reserved ).
• This results in a maximum of 127 Class A networks,
• with 16,777,214 hosts per network! (extremely large networks )
• Example of a Class A address:
• Address: 64.32.254.100
• net Mask: 255.0.0.0
13
IP address Classes
•
•
•
•
Class B networks range from 128 to 191.
The default net mask is 255.255.0.0;
thus, by default, the first two octets define the network,
and the last two octets define the host.
• N of networks : from 128.0 to 191.255. (2^14)
• This results in a maximum of 16,384 Class B networks,
• with 65,534 hosts per network. (2^16-2) (for medium sized
company)
• Example of a Class B address:
● Address: 152.4.12.195
● net Mask: 255.255.0.0
14
IP address classes
•
•
•
•
Class C networks range from 192 to 223.
The default net mask is 255.255.255.0;
thus, by default, the first three octets define the network,
and the last octet defines the host.
•
•
•
•
N°of networks: from 192.0.0 to 223.255.255
This results in a maximum of 2,097,152 Class C networks (2^21),
with 254 (2^8 -2) hosts per network.
Example of a Class C address:
– Address: 207.79.233.6
– net Mask: 255.255.255.0
15
Question
• Netmask associated to IP@ 34.208.123.12 ?
(A) 255.0.0.0
(B) 255.255.0.0
(C) 255.255.255.0
(D) 255.255.255.255
16
IP classfull problems
• 1-Lack of Internal Address Flexibility
– big companies get assigned a rather large (Class B) or truly enormous
(Class A) block of addresses,
– all of which is considered by the Internet routers a single “network”
with one “network ID”.
– Now, imagine that you are running a medium-to-large-sized company
with 5,000 computers, and you are assigned a Class B address for your
network.
– Do you really have 5,000 computers all hooked into a single network?
– Yet you would be forced to try to fit all of these into a single IP
“network” in the original “classful” method. There was no way to
create an internal hierarchy of addresses.
17
IP Classfull problems
• 2- Inefficient Use of Address Space:
– The existence of only three block sizes (classes A, B
and C) leads to waste of limited IP address space.
• 3- Proliferation of Router Table Entries
– As the Internet grows, more and more entries are
required for routers to handle the routing of IP
datagrams,
– which causes performance problems for routers.
– Attempting to reduce inefficient address space
allocation leads to even more router table entries.
18
Rmqs
• Two addresses have been reserved on each network for special
use.
• Each network must have
– a network address,
– and a broadcast address.
• Neither of these addresses can be assigned to a host device.
• The network address is used to identify the network itself.
• Routing tables contain lists of networks, and each network is
identified by its address.
• Network addresses contain all 0 bits in the host portion of
the address.
– For example, the following is a network address:
192.168.1.0/24
19
• The broadcast address identifies all hosts on a particular
network.
• A packet sent to the broadcast address will be received and
processed by every device on that network.
• Broadcast addresses contain all 1 bits in the host portion of
the address.
• For example, the following is a broadcast address:
192.168.1.255/24.
• Broadcasts are one of three types of IP packets:
– Unicasts are packets sent from one host to another host
– Multicasts are packets sent from one host to a group of
hosts
– Broadcasts, as stated earlier, are packets sent from one
host to all other hosts on the local network
20
Subnetting
• way to create an internal hierarchy of addresses.
• Internal to a network of Class A, B, C
• 3 levels : network, subnetwork, host
• Avoid requesting more network @ from any classes
21
Subnetting
• Subnetting is the process of creating new networks (or subnets)
by stealing bits from the host portion of a subnet mask.
• Stealing bits from hosts creates more networks but fewer hosts
per network.
• Consider the following Class C network: 192.168.254.0
• The default subnet mask for this network is 255.255.255.0.
• This single network can be segmented, or subnetted, into multiple
networks.
• For example, assume a minimum of 10 new networks are
required.
• Resolving this, is possible using the following magical formula:
– 2n
• The exponent ‘n’ identifies the number of bits to steal from the
host portion of the net mask.
22
•
•
•
•
•
•
•
•
•
The default Class C mask (255.255.255.0) looks as follows in binary:
– 11111111.1111111.1111111.00000000
There are a total of 24 bits set to 1, which are used to identify the network.
There are a total of 8 bits set to 0, which are used to identify the host,
and these host bits can be ‘stolen.’
Stealing bits essentially involves changing host bits (set to 0 or off) in the net
mask to network bits (set to 1 or on).
Network bits in a net mask must always be sequential, skipping bits is not
allowed.
Consider the result if 3 bits are stolen.
Using the above formula:
– 2n = 23 = 8 new networks created
– However, a total of eight new networks does not meet the original requirement
of at least 10 networks.
– Consider the result if four bits are stolen: 2n = 24 = 16 new networks created.
A total of sixteen new networks does meet the original requirement.
– Stealing four host bits results in the following new subnet mask:
11111111.11111111.11111111.11110000 = 255.255.255.240
23
Subnetting
• In the previous example, a Class C network was subnetted to
create 16 new networks,
• using a subnet mask of 255.255.255.240 (or /28 ).
• Four bits were stolen in the subnet mask,
• leaving only four bits for hosts.
• To determine the number of hosts this results in, for each of
the new 16 networks,
• the used formula is: 2n – 2.
• Consider the result if four bits are available for hosts:
• 2n – 2 = 24 – 2 = 16 – 2 = 14 usable hosts per network
• Thus, subnetting a Class C network with a /28 mask creates 16
new networks, with 14 usable hosts per network.
24
Subnetting
• Determining the ‘Range’ of Subnetted Networks
• The ‘shortcut’ method involves taking the subnet mask
(255.255.255.240 from the previous example), and subtracting
the subnetted octet (240) from 256.
– 256 – 240 = 16
– the first network will begin at 0. Then, simply continue adding
16 to list the first address of each new network:
0 16 32 48 64 80 96 112 128 144 160 176 192 208 224
240
25
Subnetting
Hosts on the same network (such as 192.168.254.2 and
192.168.254.14) can communicate freely.
• Hosts on different networks (such as 192.168.254.61 and
192.168.254.66) require a router to communicate.
26
Question
• Network @ 135.28.0.0
– Class? (A/B/C/D)
– 10 subnets, how many bits do we need
• A) 3 bits
• B) 4 bits
• C) 5 bits
– Subnet mask 255.255.240.0
– Subnets size
• A) same
• B) variable
27
Question
• How many networks of variable length should we design
– A) 4
– B) 5
– C) 6
– D) 7
28
Review - Magic Numbers
• To make the job of subnetting easier,
there is a method that allows you to
calculate a "magic" number.
• The magic number we're looking for
is the number of addresses in each
network, including the network,
broadcast and host range.
• The calculation 2number_ of_ host_ bits yields the "magic"
number.
• We have 5 host bits remaining so…..
• 25 = 32 - our "magic" number.
29
Review - Subnetting - Class C
• Network: 192.168.80.0 Subnet Mask: 255.255.255.224
• Network: 27 bits Host: 5 bits Magic Number: 25 = 32
ID
Network
Address
Subnet Address
Range
Broadcast
Address
0
192.168.80.0
192.168.80.1 – 192.168.80.30
192.168.80.31
1
192.168.80.32
192.168.80.33 – 192.168.80.62
192.168.80.63
2
192.168.80.64
192.168.80.65 – 192.168.80.94
192.168.80.95
3
192.168.80.96
192.168.80.97 – 192.168.80.126
192.168.80.127
4
192.168.80.128 192.168.80.129 – 192.168.80.158 192.168.80.159
5
192.168.80.160 192.168.80.161 – 192.168.80.190 192.168.80.191
6
192.168.80.192 192.168.80.193 – 192.168.80.222 192.168.80.223
7
192.168.80.224 192.168.80.225 – 192.168.80.254 192.168.80.255
30
Dividing Networks Into the Right Size
192.168.80.192/27
192.168.80.32/27
192.168.80.160/27
192.168.80.0/27
192.168.80.128/27
192.168.80.64/27
192.168.80.96/27
Dividing Networks Into the Right Size
Available:
Required:
Wasted:
30
5
25
Available:
Required:
Wasted:
30
2
28
192.168.80.0/27
192.168.80.128/27
Available:
Required:
Wasted:
30
4
26
192.168.80.96/27
Assigned
Required
Wasted
Network 1
30
5
25
Network 2
30
5
25
Network 3
30
4
26
Network 4
30
5
25
Network 5
30
2
28
Network 6
30
2
28
Network 7
30
5
25
Total
210
28
182
Subnetting Problem
• Site with a Class C address 192.15.34.0, needs five subnets
with 60, 60, 60, 30, and 30 hosts
• Problems
– cannot use subnet mask 255.255.255.192, since it allows
only 4 subnets, each with 62 hosts
– cannot use subnet mask 255.255.255.224, since it allows 8
subnets, each with only 30 hosts
34
Variable Length Subnet Masking
(VLSM)
• A serious limitation of using only a single subnet mask
across a given network-prefix (the number of network
or 1 bits in the mask) was that an organization is locked
into a fixed-number of fixed-sized subnets.
• VLSM enables a network number to be configured with
different subnet masks on different interfaces.
– Subnet an already subnetted network address.
– Conserves IP addresses.
– More efficient use of available address space.
• Allows for more hierarchical levels within an
addressing plan.
35
Variable Length Subnet Masking (VLSM)
10.0.0.0/8
Subnet using /16
Subnet
1st Host
Last Host
Broadcast
10.0.0.0/16
10.0.0.1
10.0.255.254
10.0.255.255
10.1.0.0/16
10.1.0.1
10.1.255.254
10.1.255.255
10.2.0.0/16
10.2.0.1
Subnet
10.2.255.254
1st Host
10.2.255.255
Last Host
Broadcast
10.3.0.0/16
10.2.0.0/24
10.3.0.1
10.2.0.1
10.3.255.254
10.2.0.254
10.3.255.255
10.2.0.255
Sub-subnet
Etc.
Using /24
10.255.0.0/16
10.2.1.0/24
10.2.1.1
10.2.1.254
10.2.1.255
10.2.2.0/24
10.255.0.1
Etc.
10.2.255.0/24
10.2.2.1
10.2.2.254
10.255.255.254
10.255.255.255
10.2.255.1
10.2.255.254
10.2.2.255
10.2.255.255
Variable Length Subnet Masking
192.168.20.64/27
192.168.20.128/27
(VLSM)
192.168.20.0/27
192.168.20.32/27
192.168.20.128/27
192.168.20.96/27
192.168.20.64/27
7 Networks with 30 usable
addresses for each network
Wasted 28 addresses on
each WAN link
38
Variable Length Subnet Masking
192.168.20.32/27
192.168.20.96/27
(VLSM)
192.168.20.0/27
192.168.20.192/30
192.168.20.64/27
192.168.20.196/30
192.168.20.200/30
39
Variable Length Subnet Masking (VLSM)
Original
255.255.255.224
Subnet Mask
Magic Number
11100000
= 32
255.255.255.252
111111
00
Sub-Subnet
Mask
Magic Number
= 4
192.168.20.0
00000000
110000 00
192.168.20.192
192.168.20.32
00100000
110001 00
192.168.20.196
192.168.20.64
01000000
110010 00
192.168.20.200
192.168.20.96
01100000
110011 00
192.168.20.204
192.168.20.128
10000000
110100 00
192.168.20.208
192.168.20.160
10100000
110101 00
192.168.20.212
192.168.20.192
11000000
110110 00
192.168.20.216
192.168.20.224
11100000
110111 00
192.168.20.220
Variable Length Subnet Masking
(VLSM)
“If you know how to subnet, you can do VLSM.”
What’s the trick?
Always satisfy the requirements of your
biggest LAN and then work your way
down ….
41
Variable Length Subnet Masking
(VLSM)
• Steps for VLSM:
1. List the number of hosts required per network
beginning with the largest to the smallest.
2. Convert the subnet mask to binary.
3. Draw a line where the network portion ends.
4. Ask yourself the question… How many bits do I
need to support the required number of hosts?
5. Move the line to show your new network portion.
6. Determine your new magic number????.
7. Finish subnetting using the new magic number.
• The starting address is always the first network.
42
Question
43
CIDR Supernetting
Using VLSM and subnetting increase the number
of sub-networks.
Routes to each network have to be advertised to
the Internet and added to routers.
This increase the size of routing table
Supernetting is a new addressing scheme that
allows for more efficient allocation of IP
addresses
Aggregating network addresses by decreasing
the number of bits recognized as the network
44
Classless IP Addressing
• To CIDR-compliant routers, address class is meaningless.
– The network portion of the address is determined by the
network subnet mask, also known as the network prefix, or
prefix length (/8, /19, etc.).
• The network address is no longer determined by the class
of the address.
45
CIDR and Route Summarization
• The capability for routes to be summarized as a single
route helped reduce the size of Internet routing tables.
• A Supernet summarizes multiple network addresses with a
mask that is less than (or a summary of) the classful mask.
46
CIDR and Route Summarization
Networks to be summarized MUST be
contiguous.
192.168.0.0/23
11000000.10101000.00000000.00000000
192.168.2.0/23
11000000.10101000.00000010.00000000
192.168.4.0/22
11000000.10101000.00000100.00000000
192.168.8.0/21
11000000.10101000.00001000.00000000
Summary 192.168.0.0/20
11000000.10101000.00000000.00000000
• Networks are converted to binary.
• The summary route is comprised of the least
number of bits that are common to all subnets.
47
CIDR and Route Summarization
Summary
192.168.0.0/23
11000000.10101000.00000000.00000000
192.168.2.0/23
11000000.10101000.00000010.00000000
192.168.4.0/22
11000000.10101000.00000100.00000000
192.168.8.0/21
11000000.10101000.00001000.00000000
192.168.0.0/20
11000000.10101000.00000000.00000000
• Requires a classless routing protocol (RIPv2, EIGRP, OSPF).
• The subnet mask of the network MUST be included with
the routing update.
48
Classless Routing Protocol
R2 sends a summarized
route out s0/0/1
Classful Update
R3 applies the default
/16 subnet mask
49
Classless Routing Protocol
CIDR
Classless Update
Networks 172.16.0.0/16,
172.17.0.0/16, 172.18.0.0/16,
and 172.19.0.0/16 can be
summarized into the
Supernet 172.16.0.0/14.
The /14 (255.252.0.0)
subnet mask is included
in the routing update.
50
CIDR Example
• 16 class C addresses: mask 255.255.255.0
192.92.240.0
192.92.248.0
192.92.241.0
192.92.249.0
192.92.242.0
192.92.250.0
192.92.243.0
192.92.251.0
192.92.244.0
192.92.252.0
192.92.245.0
192.92.253.0
192.92.246.0
192.92.254.0
192.92.247.0
192.92.255.0
• We look to the binary representation of the third octet of these addresses
51
52
• The first four bits in this octet do not change, but the last four
bits do.
• The last four bits are represented in their full range of values,
from 0000 to 1111.
• So, if we choose to ignore the last four bits in this octet, we get
a single address that represents the full range of 16
addresses.
• That address is 192.92.240.0 (the first address of the group),
and its mask is 255.255.240.0 (the natural mask minus the
last four bits).
• This mask is termed the supernet mask.
• Thus, the single advertisement of 192.92.240.0 with supernet
mask 255.255.240.0 is the equivalent of 16 advertisements
for addresses 192.92.240.0 through 192.92.255.0.
53
CIDR:‘Classless Inter Domain Routing’
• Instead of being limited to network identifiers (or "prefixes") of 8,
16 or 24 bits,
• CIDR currently uses prefixes anywhere from 13 to 27 bits.
• This allows for address assignments that much more closely fit an
organization's specific needs.
54
Cont.
The number of addresses in a CIDR block is a power of 2,
based on the number of bits that is not recognized by the
mask
Example: 192.92.240.0/20.  2 power 12 possible addresses
Each time we decrease the mask length, we increase the
number of possible networks by a factor of 2.
240 = 1111 0000
241= 1111 0001
55
Example 1
• We desire building a new IP network : containing 2000 hosts.
• How many bits do we need??
• We need a block of addresses allowing 2**11 : => 2048>2000 addresses
– =>the mask (32-11)=> /21.
•
•
•
•
Suppose that IP has a free block 194.16.32.0/19
Can this block be used??
How many blocks can be given to the customer??
What are these blocks ??
–
–
–
–
Net (1) 194.16.32.0/21
Net (2) 194.16.40.0/21
Net (3) 194.16.48.0/21
Net (4) 194.16.56.0/21
56
Example 2
Suppose this is a hot @; 172.16.19.40/21 :
Q : Mask ?
R : 255.255.248.0.
Q : Does this host belong to a subnet??
Q :How many bits are allocated for subnetting ?
R : Class B, 5bits for subnetworks
Q : How many subnets are available ?
R:
Q : How many hosts/subnets ?
R : 32 -21 = 11 bits. 2048. 2046 host @.
57
Exemple
Q : To which subnet belong the host of the example ?
R : 172.16.16.0.
Q : The broadcat @ for the subnet to which belong the host of the example ?
R : 172.16.23.255.
58