Ch06 Routing
Ch06 Routing
• Any IP address within the network 127.0.0.0/8 refers to the local host.
• Used by the host different application to communicate with each other.
• Useful for testing purposes.
C:\Users\Admin>
2
Host Can Send a Packet To a Local Host
Hosts are on the same network : sending host and receiving host share the same network address.
R1
.10 G0/1
PC3 .1
.11 192.168.11.0/24
PC4
3
Host Can Send a Packet To a Remote Host
When a host on a remote network, the hosts do not share the same network address.
• A default gateway IP address is required.
.10
PC1 192.168.10.0/24
.1
.11 G0/0
PC2
R1
.10 G0/1
PC3 .1
.11 192.168.11.0/24
PC4
4
Host Can Send a Packet To a Remote Host
• The default gateway is the device (i.e, router) that routes traffic from the local network to
remote networks.
• A host sending a packet to a remote host does not maintain routing information beyond
the local network.
• The default gateway maintains a routing table containing directly connected and remote
network route information.
.10
PC1 192.168.10.0/24
.1
.11 G0/0
PC2
R1
.10 G0/1
PC3 .1
.11 192.168.11.0/24
PC4
5
Default gateway
Hosts doesn’t know the address of every device on the Internet it might communicate to.
When a host needs to communicate with another network, an intermediary device, or router, acts as a
gateway to the other network.
Each host contain a routing table that contains at the minimum a “gateway”.
The default gateway IP address is typically a host IP address “router” which is on the same network as
the host itself which is used to forward packets out of the network.
• Default gateway IP address to reach all devices outside its own network
Host Routing Table
netstat –r
Or route print
7
Subnet Mask
• When the host is to send data , it uses the subnet mask to check if the destination packet is on the same
network.
• So, it knows whether to encapsulate the IP packet into an Ethernet frame with:
• The Destination MAC Address of the host with the Destination IP address of the packet.
8
IP Addresses – First look
172.16.10.100/16
Network Address
192.168.1.0/30
172.16.10.55/16
ISP
Internet
192.168.1.2/30
172.16.1.1/16
192.168.1.1/30 172.16.10.3/16
9
IP Addresses – First look
Network Address
192.168.1.0/30
172.16.10.55/16
ISP Gateway: 172.16.1.1
Internet
192.168.1.2/30
172.16.1.1/16
192.168.1.1/30 172.16.10.3/16 Gateway: 172.16.1.1
• All hosts in the same network will typically have the same default gateway IP address.
• The ipconfig or ifconfig commands at the command line are used in windows and Linux .
10
Default Gateway
11
Configuring Default Gateway on Hosts
• The default gateway address can be configured on the host manually or learned dynamically.
12
Default Gateway – ipconfig
C:\Users\Admin>ipconfig
Windows IP Configuration
C:\Users\Admin>
13
Host Routing Table
C:\Users\PC1> netstat -r
<Output omitted>
14
netstat IPv4 Information Lists reachable networks
<Output omitted>
15
0.0.0.0
• This is the local default route.
• Forwards all non-matching packets.
netstat IPv4 Information • All non-matching destination routes are sent to 192.168.10.1
(R1) exiting from the interface with IP address 192.168.10.10.
127.0.0.0 – 127.255.255.255
•These loopback addresses all relate to the direct connection and
provide services to the local host.
192.168.10.0 - 192.168.10.255
• These addresses all relate to the host and local network.
• 192.168.10.0 - The local network route address.
C:\Users\PC1> netstat -r • 192.168.10.10 - The address of the local host.
• 192.168.10.255 - The network broadcast address.
<Output omitted>
224.0.0.0
• Special multicast addresses reserved for use through either
IPv4 Route Table
the loopback interface or the host IP address.
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.10.1 192.168.10.10 25
127.0.0.0 255.0.0.0 On-link 127.0.0.1 306
127.0.0.1 255.255.255.255 On-link 127.0.0.1 306
127.255.255.255 255.255.255.255 On-link 127.0.0.1 306
192.168.10.0 255.255.255.0 On-link 192.168.10.10 281
192.168.10.10 255.255.255.255 On-link 192.168.10.10 281
192.168.10.255 255.255.255.255 On-link 192.168.10.10 281
224.0.0.0 240.0.0.0 On-link 127.0.0.1 306
224.0.0.0 240.0.0.0 On-link 192.168.10.10 281
255.255.255.255 255.255.255.255 On-link 127.0.0.1 306
255.255.255.255 255.255.255.255 On-link 192.168.10.10 281
===========================================================================
255.255.255.255
<Output omitted> • Limited broadcast IP address values for use through either the
loopback interface or the host IP address.
16
PC1 wants to ping PC2.
Which route will be chosen?
C:\Users\PC1> netstat -r
<Output omitted>
<Output omitted>
17
PC1 wants to ping 10.10.10.10.
Which route will be chosen?
C:\Users\PC1> netstat -r
<Output omitted>
<Output omitted>
18
S1# show running-config
Building configuration...
!
Default Gateway on a Switch <output omitted>
service password-encryption
!
hostname S1
!
Interface Vlan1
ip address 192.168.10.5
!
ip default-gateway 192.168.10.1
<output omitted>
.10
PC1 192.168.10.0/24 192.168.11.0/24
.1 .1
G0/0 G0/1 S2
S1 R1
.11 .5
PC2
• A switch must (should) also be configured with a default gateway address, because packets
that originate from the switch are handled just like packets that originate from a host device.
• This is not used by normal user frames!
• Use the ip default-gateway global config command.
19
Default Gateway on a Switch
• For example, the administrator wants to Telnet to the S1.
• Without the default gateway configured on S1, packets from S1 would not be able to
reach the administrator at 192.168.11.10.
S1# show running-config
Building configuration...
!
<output omitted>
service password-encryption
!
hostname S1
!
Interface Vlan1
ip address 192.168.10.5
!
ip default-gateway 192.168.10.1
<output omitted>
.10
PC1 192.168.10.0/24 192.168.11.0/24
.1 .1
S1 G0/0 G0/1 S2
.11 R1
PC2 .5
20
Router Routing Tables
Packet Forwarding
• Routing is done packet-by-packet and hop-by-hop.
• At each hop, the router examines the destination IP address for each packet and then checks the
routing table for forwarding information
• The router will do one of 3 things with the packet: Forward it to the default route “gateway” , Forward
it to the destination host or Drop it
23
Routing IP Packets
A router goal is to forward a packet destined to outside the network to its correct
destination!
To do so, a router keeps track of local and remote networks.
This information is stored in a routing table.
24
Routing IP Packets
25
Router Operational Goal
26
Routing IP Packets
27
Routing IP Packets
28
Routing IP Packets
29
Routing IP Packets
30
Routing Table Routes
31
Local Net2
R2
Local Net5
Directed Connected
Network ( Local R0
Network 1)
Loc
al N
et6
R0 connect directly with
Local Networks 1, 5,6
R3
R0 connect remotely with Local Net3
Network 2 via R2 where
as R0 connect remotely Local Net4
with Networks 3 and 4 via
R3
Routing Table Routes
33
Routers and the Network Layer
34
IPv4 Router Routing Table
192.168.10.0/24 10.1.1.0/24
.10 G0/0 .10
PC1 209.165.200.224 /30
.1 .1
.225 .226
R1 S0/0/0 R2
.10 .1 .1 .10
PC2 G0/1
192.168.11.0/24 10.1.2.0/24
192.168.11.0/24
• Two routing table entries are automatically created when an active router interface is
configured with an IP address and subnet mask.
• C: Directed connected network
• Identifies a directly connected network.
• Directly connected networks are automatically created when an interface is
configured with an IP address and activated.
• L: Directed connected route
• Appeared in I.O.S (15) and might not appear before
• Identifies that this is a local route, the IP address of the interface.
• Local routes are automatically created when an interface is configured with an IP
address and activated.
36
Directly Connected Routing Table Entries
192.168.11.0/24 10.1.2.0/24
A B C
C 192.168.10.0/24 is directly connected, GigabitEthernet0/0
L 192.168.10.1/32 is directly connected, GigabitEthernet0/0
37
Remote Network Routing Table Entries
192.168.11.0/24 10.1.2.0/24
38
Destination Network
192.168.10.0/24 10.1.1.0/24
.10 G0/0 .10
PC1 209.165.200.224 /30
.1 .1
.225 .226
R1 S0/0/0 R2
.10 .1 .1 .10
PC2 G0/1
192.168.11.0/24 10.1.2.0/24
R1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
192.168.11.0/24 10.1.2.0/24
R1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
192.168.11.0/24 10.1.2.0/24
R1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Which Route?
192.168.10.0/24 64.100.0.1 10.1.1.0/24
.10 G0/0 .10
PC1 209.165.200.224 /30
.1 .1
.225 .226
R1 S0/0/0 R2
.10 .1 .1 .10
PC2 G0/1
192.168.11.0/24 10.1.2.0/24
R1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
192.168.11.0/24 10.1.2.0/24
R1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Which Route?
192.168.10.0/24 64.100.0.1 10.1.1.0/24
.10 G0/0 .10
PC1 209.165.200.224 /30
.1 .1
.225 .226
R1 S0/0/0 R2
.10 .1 .1 .10
PC2 G0/1
192.168.11.0/24 10.1.2.0/24
R1#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
45
More routing details….
• Static route
• Requires the administrator to have a good knowledge about how to reach all networks and/or
default route.
• Administrative cost - Manual configuration and maintenance of the routing table to ensure.
• If any network were modified , static routing requires the admin. to reconfigure the routing table.
• Dynamic routing – Using routing protocols “set of rules by which routers dynamically share their
routing information “.
• When a router receives information about new or changed routes, it updates its own routing table
and, in turn, passes the information to other routers.
46
Static Routing
Dynamic Routes Automatically:
• Discover remote networks
• Maintain up-to-date information
• Choose the best path to the destination
• Find new best paths when there is a topology change
Dynamic routing can also share static default routes with the other routers.
When a router is manually configured with a static route or learns about a remote network
dynamically using a dynamic routing protocol, the remote network address and next hop address
are entered into the IP routing table. As shown in the figure, if there is a change in the network
topology, the routers will automatically adjust and attempt to find a new best path.
47
Routing Protocols
Routers employing these protocols must have sufficient processing capacity to both implement the
protocol's algorithms and to perform timely packet routing and forwarding
A Quick Look at Routing
Routing – First Look
Network 192.168.1.0/24
Network 192.168.2.0/24
192.168.1.254/24
Routers know about routes either statically or dynamically using a routing protocol:
• Directly connected networks (C):
• Network addresses of its interfaces
• Remote networks : learned by static or dynamic Routing Protocol (R = RIP)
50
Routing – First Look
Network 192.168.1.0/24
Network 192.168.2.0/24
192.168.1.254/24
Destination Network
Next Hop
Metric
• Remote networks are networks not directly connected to the router (manual configuration or learned
dynamically).
Routing Table
• The router matches the destination address in the packet header with the destination network of
a route in the routing table and forwards the packet to the next-hop router specified by that
route.
53
Destination Network - Routing Table Entries
• If a route for a packet cannot be found in the routing table, and a default route is present, that
route will be used to forward the packet.
• A next-hop is the address of the device that will process the packet next.
Destination Network - Routing Table Entries
Destination Network
Next Hop
Metric
• Some routes can have multiple next-hops. This indicates that there are multiple paths to the same
destination network . The metric is used to decide which route appears on the routing table.
• If a packet arrives destined for 207.23.124.56, the router would check the table in the following order:
• 10.0.0.0
• 10.1.1.0
• 10.1.0.0
• 192.168.1.0 Since the route doesn’t exist and a default route is
configured, the packet would be forwarded to the
• 0.0.0.0
next hop.
Packet Forwarding: Route Found
L2 IP TCP DATA L2
Network 10.1.1.0
IP TCP DATA
Network 10.1.2.0
IP Address 10.1.2.2 is on
network 10.1.2.0
L2 IP TCP DATA L2
Packet Forwarding: Default Route
L2 IP TCP DATA L2
Network 10.1.1.0
IP TCP DATA
Network 10.1.2.0
IP Address 207.1.1.1 is on
network 207.1.1.0
L2 IP TCP DATA L2
Packet Forwarding: Route Not Found
?
Data for Host 207.1.1.1 /
24
L2 IP TCP DATA L2
Network 10.1.1.0
IP TCP DATA
Network 10.1.2.0
IP Address 207.1.1.1 is on
network 207.1.1.0
A Day in the Life of a Packet
60
A Day in the Life of a Packet
61
A Day in the Life of a Packet
62
A Day in the Life of a Packet
63
A Day in the Life of a Packet
64
A Day in the Life of a Packet
65
A Day in the Life of a Packet
66
A Day in the Life of a Packet
67
A Day in the Life of a Packet
68
A Day in the Life of a Packet
69
A Day in the Life of a Packet
70
A Day in the Life of a Packet
71
A Day in the Life of a Packet
72
A Day in the Life of a Packet
73
A Day in the Life of a Packet
74
A Day in the Life of a Packet
75