静态路由

拓扑:

Lo0:1.1.1.1/24---R1---------12.12.12.0/24--------R2------L00:2.2.2.2/24

 

设备配置:

system-view

[R1]int s0/2/0

[R1-Serial0/2/0]ip add 12.12.12.1 255.255.255.0

[R1-Serial0/2/0]undo shutdown

[R1]int lo0

[R1-LoopBack0]ip add 1.1.1.1 255.255.255.0

[R1]ip route-static 2.2.2.0 255.255.255.0 12.12.12.2

 

system-view

[R2]int s0/2/0

[R2-Serial0/2/0]ip add 12.12.12.2 255.255.255.0

[R2-Serial0/2/0]undo shutdown

[R2-Serial0/2/0]quit

[R2]int lo0

[R2-LoopBack0]ip add 2.2.2.2 255.255.255.0

[R2]ip route-static 1.1.1.0 255.255.255.0 12.12.12.1

查看R1的路由表:

[R1]display ip routing-table

Routing Tables: Public

        Destinations : 7        Routes : 7

 

Destination/Mask    Proto  Pre  Cost         NextHop         Interface

 

1.1.1.1/32          Direct 0    0            127.0.0.1       InLoop0

2.2.2.0/24          Static 60   0            12.12.12.2      S0/2/0

12.12.12.0/24       Direct 0    0            12.12.12.1      S0/2/0

12.12.12.1/32       Direct 0    0            127.0.0.1       InLoop0

12.12.12.2/32       Direct 0    0            12.12.12.2      S0/2/0

127.0.0.0/8         Direct 0    0            127.0.0.1       InLoop0

127.0.0.1/32        Direct 0    0            127.0.0.1       InLoop0

查看R2的路由表:

[R2]display ip routing-table

Routing Tables: Public

        Destinations : 7        Routes : 7

 

Destination/Mask    Proto  Pre  Cost         NextHop         Interface

 

1.1.1.0/24          Static 60   0            12.12.12.1      S0/2/0

2.2.2.2/32          Direct 0    0            127.0.0.1       InLoop0

12.12.12.0/24       Direct 0    0            12.12.12.2      S0/2/0

12.12.12.1/32       Direct 0    0            12.12.12.1      S0/2/0

12.12.12.2/32       Direct 0    0            127.0.0.1       InLoop0

127.0.0.0/8         Direct 0    0            127.0.0.1       InLoop0

127.0.0.1/32        Direct 0    0            127.0.0.1       InLoop0

 

测试连通性:

[R2]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=15 ms

    Reply from 1.1.1.1: bytes=56 Sequence=2 ttl=255 time=4 ms

    Reply from 1.1.1.1: bytes=56 Sequence=3 ttl=255 time=4 ms

    Reply from 1.1.1.1: bytes=56 Sequence=4 ttl=255 time=5 ms

    Reply from 1.1.1.1: bytes=56 Sequence=5 ttl=255 time=2 ms

 

  --- 1.1.1.1 ping statistics ---

    5 packet(s) transmitted

    5 packet(s) received

    0.00% packet loss

round-trip min/avg/max = 2/6/15 ms

 

 

把上的静态路由删除换为默认路由:

[R1]ip route-static 0.0.0.0 0.0.0.0 12.12.12.2

[R2]ip route-static 0.0.0.0 0.0.0.0 12.12.12.1

 

[R2]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=25 ms

    Reply from 1.1.1.1: bytes=56 Sequence=2 ttl=255 time=14 ms

    Reply from 1.1.1.1: bytes=56 Sequence=3 ttl=255 time=25 ms

    Reply from 1.1.1.1: bytes=56 Sequence=4 ttl=255 time=4 ms

    Reply from 1.1.1.1: bytes=56 Sequence=5 ttl=255 time=15 ms

 

  --- 1.1.1.1 ping statistics ---

    5 packet(s) transmitted

    5 packet(s) received

    0.00% packet loss

    round-trip min/avg/max = 4/16/25 ms