三角静态路由配置实验
事先准备:如图先配置好每个路由器接口的IP地址
第一种:只配置每个路由直连静态路由
1)在R1上配置直连的静态路由,配置Loopback0的ip地址为2.2.2.2/32
[R1]int LoopBack 0
[R1-LoopBack0]ip add 2.2.2.2 32
[R1-LoopBack0]q
[R1]ip route-static 1.1.1.1 32 192.168.10.2
[R1]ip route-static 3.3.3.3 32 192.168.30.2
2)在R2上配置直连的静态路由,配置Loopback0的ip地址为1.1.1.1/32
[R2]int LoopBack 0
[R2-LoopBack0]ip address 1.1.1.1 32
[R2-LoopBack0]q
[R2]ip route-static 2.2.2.2 32 192.168.10.1
[R2]ip route-static 3.3.3.3 32 192.168.20.2
3)在R3上配置直连的静态路由,配置Loopback0的ip地址为3.3.3.3/32
[R3]int LoopBack 0
[R3-LoopBack0]ip address 3.3.3.3 32
[R3-LoopBack0]q
[R3]ip route-static 2.2.2.2 32 192.168.30.1
[R3]ip route-static 1.1.1.1 32 192.168.20.1
4)用ping命令测试
[R3]ping 1.1.1.1
PING 1.1.1.1: 56 data bytes, press CTRL_C to break
Reply from 1.1.1.1: bytes=56 Sequence=1 ttl=255 time=70 ms
Reply from 1.1.1.1: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 1.1.1.1: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 1.1.1.1: bytes=56 Sequence=4 ttl=255 time=30 ms
Reply from 1.1.1.1: bytes=56 Sequence=5 ttl=255 time=20 ms
--- 1.1.1.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/32/70 ms
[R3]ping 2.2.2.2
PING 2.2.2.2: 56 data bytes, press CTRL_C to break
Reply from 2.2.2.2: bytes=56 Sequence=1 ttl=255 time=70 ms
Reply from 2.2.2.2: bytes=56 Sequence=2 ttl=255 time=30 ms
Reply from 2.2.2.2: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 2.2.2.2: bytes=56 Sequence=4 ttl=255 time=20 ms
Reply from 2.2.2.2: bytes=56 Sequence=5 ttl=255 time=20 ms
--- 2.2.2.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/32/70 ms
[R2]ping 2.2.2.2
PING 2.2.2.2: 56 data bytes, press CTRL_C to break
Reply from 2.2.2.2: bytes=56 Sequence=1 ttl=255 time=60 ms
Reply from 2.2.2.2: bytes=56 Sequence=2 ttl=255 time=30 ms
Reply from 2.2.2.2: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 2.2.2.2: bytes=56 Sequence=4 ttl=255 time=20 ms
Reply from 2.2.2.2: bytes=56 Sequence=5 ttl=255 time=20 ms
--- 2.2.2.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/30/60 ms
结果为全部互通
第二种:只配置每个路由非直连静态路由
1)配置R1的静态路由
[R1]ip route-static 192.168.20.0 24 192.168.30.2
[R1]ip route-static 192.168.20.0 24 192.168.10.2
[R1]ip route-static 1.1.1.1 32 192.168.30.2
[R1]ip route-static 3.3.3.3 32 192.168.10.2
2)配置R2的静态路由
[R2]ip route-static 192.168.30.0 24 192.168.20.2
[R2]ip route-static 192.168.30.0 24 192.168.10.1
[R2]ip route-static 2.2.2.2 32 192.168.20.2
[R2]ip route-static 3.3.3.3 32 192.168.10.1
3)配置R3的静态路由
[R3]ip route-static 192.168.10.0 24 192.168.20.1
[R3]ip route-static 192.168.10.0 24 192.168.30.1
[R3]ip route-static 1.1.1.1 32 192.168.30.1
[R3]ip route-static 2.2.2.2 32 192.168.20.1
[R3]ping 2.2.2.2
PING 2.2.2.2: 56 data bytes, press CTRL_C to break
Request time out
Request time out
Request time out
Request time out
Request time out
--- 2.2.2.2 ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
ping结果为无法ping通,原因例如:R1要发送 数据包到1.1.1.1,根据自己静态路由配置会先送到到R3,R3收到数据包要发送给1.1.1.1,根据自己静态路由配置又会把数据包发送给R1,由此进入了回环,解决方式还是需要在每个路由上添加直连的静态路由。