IPAddressesAndSubnetting

advertisement
Internet Addresses
(You should read Chapter 4 in Forouzan)
IP Address is 32 Bits Long
Conceptually the address is the pair (NETID, HOSTID)
Addresses are assigned by the internet company for assignment of names and numbers
ICANN
ICANN:
Protocol Support Organization (PSO)
Domain Name Supporting Organization (DNSO)
Address Supporting Organization (ASO)
Regional Internet Registries
American Registry for Internet Numbers (ARIN)
http://www.arin.net/registration/fee_schedule.html
www.arin.net
www.icann.org
1
Reference “ IP Fundamentals ” Chapter 1 and 2 by Maufer
Formats for IP addresses: (classful addressing)
Class A
Network (7 bits)
0
Class B
10
Class C
110
Class D
1110
Network (14 bits)
Network (21 bits)
Host (24 bits)
Host (16 bits)
Host (8 bits)
Multicast address (28 bits)
( There is a class E reserved for future use)
Historically a class A address was assigned to networks with > 216 (65, 536) hosts
Class B to networks with 28 (256) to 216 hosts
Class C to networks with < 28 hosts
2
Internet Addresses Cont.
For Humans easier to deal with decimal so dotted decimal notation is used.
Group 8 bits.8 bits.8 bits.8 bits and use decimal numbers
Example
Class
A
B
C
D
10000000
00001010
00000010 00011110
=> 128.10.2.30
Lowest Address
Highest Address
1.0.0.0
126.0.0.0
128.1.0.0
191.254.00
192. 0.1.0
223.255.254.0
224.0.0.0
239.255.255.255
Some addresses are reserved
Example 127.0.0.0 is reserved for loop back
3
Scaling Issues:
1. Eventual exhaustion of the IPV4 address space.
2. Ability to route traffic between ever increasing number
of networks that comprise the internet.
32
IP version 4 uses 32 bit address 2  4.3 billion addresses
and six billion live on earth at present
Classless inter-domain routing (CIDR) discussed later slowed down address
exhaustion.
4
IP addresses cont.
Class A all 0’s network number is used to represent the “ default” route ( 0.0.0.0)
this is a routing table entry which means any destination not matching any other
table entry should be sent to the default route. (more later)
Class A all 1’s network number is loopback. 127.0.0.1 usually means “ This same
machine” all 127.anything.anything.anything is loopback.
There are a total of 27 -2 = 126 class A networks.
There are 214 - 2 = 16, 382 class B networks (again all 0’s & all 1’s network
addresses reserved)
There are 221-2 = 2,097,150 class C networks.
There are 228 = 268, 435, 456 class D multicast addresses.
5
Classfull addressing allows using only the first 1,2,3 or 4 bits to determine
the class. (I.E. if MSB = 0 => class A
Notation:
Class A has 8 bit network prefix this is called a slash 8’s /8
can write 127.0.0.0 as 127/8 or 127.0.0.0/8
/ 8 prefixes ( class A)
/ 8 address block has 231 out of 232 total IP addresses
=> / 8 takes up 50% total IPV4 addresses
/ 16 prefixes ( class B) 230 total addresses => 25% total IPV4 addresses
/ 24 prefixes ( class C ) 229 out of 232 => 12.5% total IPV4 addresses
Class D with 1110 most significant bits used for multicast
Class E with 1111 most significant bits and are reserved for experimental use
6
In the Beginning
- IP addresses assigned based on request, not need
- 32 bit address was thought to be plenty
- classful addresses easy to understand and implement but not
efficient / 24 supports 254 hosts too small / 16 supports 65,534 too large
7
IP Routing
For a host IP routing is simple:
If destination is directly connected to host then IP datagram is sent directly to
the destination.
otherwise host sends datagram to a default router
The IP layer can be configured to act as a router in addition to acting as a host
A host never forwards datagrams from one of its interfaces to another, while a
router forwards datagrams
IP Layer has a routing table in memory that it searches each time it receives a
a datagram to send
Each entry in routing table contains:
- Destination IP address
- IP address of a next hop router or IP address of a directly connected network
- Flags (specify if network or host address)
- Specification of which network interface the datagram should go to for transmission
8
IP Routing Performs The Following Actions:
1. Search routing table for entry that matches complete destination IP address
2. Search table for match of destination network IP. This check must take into
account a possible “ Subnet Mask ” ( Defined Later ).
3. Search for default entry.
4. If none of the above discard and send host unreachable or network
unreachable error back.
Note: Hop by hop nature of this process.
9
Classical Subnetting
Reference “ IP Fundamentals ” Chapter 3
Before :
Network - Prefix
Host - Number
After :
Network - Prefix
Subnet - Number
Host - Number
Extended-Network-Prefix
Subnetting attacks the expanded routing table problem by making the subnet
structure of a network invisible outside the organization’s private network.
External Internet Does Not Need To Know Internal Subnet Structure
10
Example :
Internet
172. 27. 0.0. / 16
RA
Subnet 1
RC
Subnet 3
Subnet 4
RB
Subnet 2
RD
Subnet 5
Internet sees
RA
RB
I need 5 subnets so I use 3 bits in the subnet - number field
11
This means I have
Subnet Number
0
1
2
3
4
5
6
7
172.27.0.0
172.27.32.0
172.27.64.0
172.27.96.0
172.27.128.0
172.27.160.0
172.27.192.0
172.27.224.0
Binary representation
of least-significant
two bytes
Available host addresses
within each subnet
00000000.00000000
00100000.00000000
01000000.00000000
01100000.00000000
10000000.00000000
10100000.00000000
11000000.00000000
11100000.00000000
0.1- 31. 254
32.1- 63.254
64.1- 95.254
96.1-127.254
128.1-159.254
160.1-191.254
192.1-223.254
224.1-255.254
Need a method to know how many bits are used for subnet-number
=> subnet mask
In this example the subnet mask is 255.255.224.0
11111111.11111111.11100000.00000000
12
Subnet Mask
At boot time a machine gets its own IP address ( stored on disk for example )
Host also needs to be told how many bits are to be used for subnet ID and how many
for host ID. This is the subnet mask.
Subnet mask is 32 bit value containing “one bits” for the network ID and subnet ID,
“zero valued bits” for host ID.
Two examples for class B addresses:
16 bits
Class B
Net ID
Subnet mask 11111111 11111111
8 bits
8 bits
Subnet ID
Host ID
11111111
00000000 = 0Xff ff ff 00
This is a /24 extended network prefix
= 255.255.255.0
(Subnet masks are only occasionally written in Hexadecimal)
Class B
16 bits
Net ID
Subnet mask 11111111 11111111
10 bits
6 bits
Subnet ID
11111111
This is a /26 extended network prefix
Host ID
11
000000 = 0Xff ff ff C0
= 255.255.255.192
13
When a host is given its own IP address and its subnetwork
mask it can then figure out:
•
Am I class A, B, or C address ?
( Look at higher order bits )
•
Where is the boundary between the network ID and the subnet ID ?
( Defined by class definition )
•
Where is the boundary between the subnet ID and the host ID ?
( Host ID is 0’s in mask )
14
Subnet Addressing
Hosts are required to consider the Host ID Portion of an IP address as a Subnet ID
Part and a Host ID Part.
Class A and class B addresses have too many bits allocated for the host ID 224 -2 and 216-2
respectively (-2 address because all 0’s all 1’s for a host ID not allowed )
Example:
16 Bits
Class B
Net ID = 130.207
8 Bits
Subnet ID
8 Bits
Host ID
=> 256 subnets with 254 hosts per subnet (Assuming can use all 1’s and all 0’s subnet)
Subnet hides the details of an internal network from external routers so that the external
Router table is smaller
To reach any host whose ID address begins with 130.207 external routers only
need to know the path to the “ Gateway” router for the entire subnetwork.
15
130.207.1.1
Gateway
........ etc
130.207.230.0
130.207.231.0
* Aside: A host address has a non zero ID and ID’s one host, a network address has
a host ID of Zero and ID’s all hosts on that network.
If we used multiple class C addresses external routing tables need at most one
entry for each of the multiple class C addresses.
Subnetting reduces the size of routing tables.
16
Example:
For a class B host address of 140.252.1.1 and a subnet mask of 255.255.255.0
Note we have 8 bits for subnet and 8 bits for host ID
• If a destination IP address is 140.252.4.5
16 bits
Class B
Subnet mask
140
8 bits
252
11111111
11111111
Network
Class B
140
8 bits
1
1
11111111
00000000 = 255.255.255.0
Subnet
252
4
5
The network ID’s are the same ( 140.252 ) the subnetwork ID’s are different ( 1 and 4 )
17
Cont
• If the destination IP address is 140.252.1.22 the network ID’s are the same (140.252)
the subnet ID’s are the same (1) the host ID’s are different.
• If the destination IP address is 192.43.235.6 ( This is a class C address )
The network ID’s are different
IP routing function makes comparisons like this all the time
[ REF: “TCP/IP Illustrated vol 1,” Stevens CH 3]
18
Subnet addressing Plan
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 on largest subnet today?
4 How many hosts on largest subnet in future?
Example Problem:
An organization has been assigned the network number 193.1.1.0/24 and it needs
to define six subnets. The largest subnet is required to support 25 hosts.
Answer:
6 subnets => 23 = 8
3 bits
Use a /27 extended - network - prefix
=> 255.255.255.224
This leaves 5 bits to define host addresses on each subnet since all 0’s and all 1’s host
19
addresses are reserved there are 25 - 2 = 30 assignable host addresses
Cont
This is >= 25 specified so ok
Base Net
Subnet # 0
#1
#2
#3
#4
#5
#6
#7
Note:
11000001 . 00000001 . 00000001 . 00000000 = 193. 1. 1. 0/24
11000001 . 00000001 . 00000001 . 00000000 = 193. 1.1.0/27
. 001
= 193. 1.1.32/27
. 010
= 193. 1.1.64/27
. 011
=
.96/27
. 100
=
.128/27
. 101
=
.160/27
. 110
=
.192/27
. 111
=
.224/27
All multiples of subnet #1
(the 32)
20
All 0’s and all 1’s subnets
Initially all 0’s and all 1’s subnets were forbidden. This was true to eliminate the following
confusion: ( in a classful router )
When 193. 1. 1. 0 is an advertised route we do not know for example if we are advertising
193 .1 .1 . 0/24 11000001. 00000001. 00000001. 000 00000
24 bits
or
193 .1 .1 . 0/27 11000001. 00000001. 00000001. 000 00000
27 bits
Which is a subnet with 000 in the Extended-Network-Prefix
- Without knowing the Prefix - Length or mask, a router cannot tell the difference in these
two cases. ( Is it a route to an all 0’s subnet or is it a route to entire network? )
- Early routing protocols like RIP-1 do not supply a mask or Prefix - Length with each route
- Now days, with the development of routing protocols that do carry this info you can use
all 0’s and all 1’s subnet
21
All 0’s And All 1’s Host Addresses
All 0’s host number is used to identify the base network ( or subnetwork )
All 1’s host number represents broadcast address for the network ( or subnetwork )
Example Possible Host Addresses For A Subnet
Given subnet #2
Host #1
.
.
.
Host #30
11000001.00000001. 00000001. 01000000 = 193.1.1.64/27
00001 = 193.1.1.65
.
.
.
.
.
.
11110 = 193.1.1.94
Broadcast For This Subnet is
Aside:
11111 = 193.1.1.95
One can deploy network numbers from the private address space
( see RFC - 1918 ) for internal connectivity and use a network address
translator ( NAT ) to provide external internet access
22
Download