靜態路由和默認路由
實驗目的
通過本實驗,需要掌握以下技能:
1) 路由表的概念
2) IP route 命令的使用
3) 根據需求正確配置靜態路由
4) 根據需求使用默認路由
拓撲結構
實現1.1.1.0/24, 2.2.2.0/24, 3.3.3.0/24網絡之間能互相通信
實驗步驟
n 步驟1:在各路由器上配置IP 地址、保證直連鏈路的連通性
R2(config)#int loopback0
R2(config-if)#ip address 2.2.2.2 255.255.255.0
R2(config)#int s1/0
R2(config-if)#ip address 12.1.1.2 255.255.255.0
R2(config-if)#no shutdown
R1(config)#int loopback0
R1(config-if)#ip address 1.1.1.1 255.255.255.0
R1(config)#int s1/0
R1(config-if)#clock rate 64000
R1(config-if)#ip address 12.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config)#int s1/1
R1(config-if)#clock rate 64000
R1(config-if)#ip address 13.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R3(config)#int loopback0
R3(config-if)#ip address 3.3.3.3 255.255.255.0
R3(config)#int s1/1
R3(config-if)#ip address 13.1.1.3 255.255.255.0
R3(config-if)#no shutdown
n 步驟2:R2 上配置靜態路由
R2(config)#ip route 1.1.1.0 255.255.255.0 s1/0
// 下一跳為接口形式,s1/0是點到點的鏈路,注意應該是R2上的s1/0
R2(config)#ip route 3.3.3.0 255.255.255.0 12.1.1.1
// 下一跳為IP地址形式,12.1.1.1是R1上的IP地址
n 步驟3:R1 上配置靜態路由
R1(config)#ip route 2.2.2.0 255.255.255.0 s1/0
R1(config)#ip route 3.3.3.0 255.255.255.0 s1/1
n 步驟4:R3 上配置靜態路由
R3(config)#ip route 1.1.1.0 255.255.255.0 s1/1
R3(config)#ip route 2.2.2.0 255.255.255.0 s1/1
實驗調試
n 在R2,R1,R3上查看路由表
R2#show ip route
Codes: 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
i - IS-IS, su - IS-IS summary, 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
Gateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets
S 1.1.1.0 is directly connected, Serial1/0
2.0.0.0/24 is subnetted, 1 subnets
C 2.2.2.0 is directly connected, Loopback0
3.0.0.0/24 is subnetted, 1 subnets
S 3.3.3.0 [1/0] via 12.1.1.1
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial1/0
R1#show ip route
Codes: 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
i - IS-IS, su - IS-IS summary, 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
Gateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
2.0.0.0/24 is subnetted, 1 subnets
S 2.2.2.0 is directly connected, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
S 3.3.3.0 is directly connected, Serial1/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial1/0
13.0.0.0/24 is subnetted, 1 subnets
C 13.1.1.0 is directly connected, Serial1/1
R3#show ip route
Codes: 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
i - IS-IS, su - IS-IS summary, 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
Gateway of last resort is not set
1.0.0.0/24 is subnetted, 1 subnets
S 1.1.1.0 is directly connected, Serial1/1
2.0.0.0/24 is subnetted, 1 subnets
S 2.2.2.0 is directly connected, Serial1/1
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
13.0.0.0/24 is subnetted, 1 subnets
C 13.1.1.0 is directly connected, Serial1/1
n 在各路由器上ping其它路由器的環回口
R2#ping 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/20/60 ms
R2#ping 3.3.3.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
R2#ping 3.3.3.3 source 2.2.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
Packet sent with a source address of 2.2.2.2
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/44/92 ms
【實驗結論】
1) 各路由器上ping loopback地址所在的直連網段都能通
2) R1上ping 2.2.2.2和3.3.3.3都能通
3) R2上ping 3.3.3.3和R3上ping 2.2.2.2是不通的,但R2上ping 3.3.3.3 source 2.2.2.2和R3上ping 2.2.2.2 source 3.3.3.3能通
【提示】
用ping測試不設置源IP地址,默認以接口地址為源地址,查看R3的路由表,沒有到目標網段12.1.1.0的路由條目,故R3無法響應R2的報文
【解決方法】
R3(config)#ip route 12.1.1.0 255.255.255.0 s1/1
R3(config)#ip route 0.0.0.0 0.0.0.0 s1/1