实验目的:

1、掌握静态路由的基本配置。

2、掌握静态路由两种写法的区别。

实验拓扑:

实验步骤:

1、依据图中拓扑配置各设备的IP地址,并保证直连连通性;

在R1上做如下配置:

R1(config)#int f0/0

R1(config-if)#no shutdown

R1(config-if)#ip address 12.1.1.1 255.255.255.0

R1(config-if)#exit

R1(config)#int loopback 1

R1(config-if)#ip address 1.1.1.1 255.255.255.255

R1(config-if)#exit

在R2上做如下配置:

R2(config)#int f0/0

R2(config-if)#no shutdown

R2(config-if)#ip address 12.1.1.2 255.255.255.0

R2(config-if)#exit

R2(config)#int loopback 1

R2(config-if)#ip address 2.2.2.2 255.255.255.255

R2(config-if)#exit

在R1上进行直连连通性测试:

R1#ping 12.1.1.2


Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 12.1.1.2, timeout is 2 seconds:

.!!!!

Success rate is 80 percent (4/5), round-trip min/avg/max = 28/36/48 ms

此时说明直连连接没有问题。

2.通过部署静态路由,使得R1和R2可以相互Ping通对方环回接口,如下:

R1(config)#ip route 2.2.2.2 255.255.255.255 12.1.1.2 

R2(config)#ip route 1.1.1.1 255.255.255.255 f0/0

查看路由表,R1路由表如下:

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/32 is subnetted, 1 subnets

C       1.1.1.1 is directly connected, Loopback1

     2.0.0.0/32 is subnetted, 1 subnets

S       2.2.2.2 [1/0] via 12.1.1.2

     12.0.0.0/24 is subnetted, 1 subnets

C       12.1.1.0 is directly connected, FastEthernet0/0

R2路由表如下:

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/32 is subnetted, 1 subnets

S       1.1.1.1 is directly connected, FastEthernet0/0 

     2.0.0.0/32 is subnetted, 1 subnets

C       2.2.2.2 is directly connected, Loopback1

     12.0.0.0/24 is subnetted, 1 subnets

C       12.1.1.0 is directly connected, FastEthernet0/0

此时在R1和R2的路由表中生成“S”开头的静态路由,可以观察到两种静态路由写法得到的路由有差异,下一跳写法管理距离为1,本地出接口写法管理距离为0。

3、在路由器上测试静态路由,如下:

R1#ping 2.2.2.2 source 1.1.1.1


Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:

Packet sent with a source address of 1.1.1.1

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 28/38/52 ms

可以看出,通过部署静态路由使得全网连通,此实验完成。