网络拓扑图:
规模比较小,采用静态路由和默认路由互通。
一、IP地址配置
已AR1为例子:
<AR1>system-view --进入系统视图模式
[AR1]sysname R1 ---修改路由器名字
[R1]interface LoopBack 0 ---进入接口视图模式
[R1-LoopBack0]ip address 10.0.1.1 24 ---配置接口ip地址
//[R1-LoopBack0]ip address 10.0.1.1 255.255.255.0 子网掩码也可以这样子的
[R1-LoopBack0]quit ---退出接口视图模式
[R1]int s4/0/0 ---命令可以缩写
[R1-Serial4/0/0]ip add 10.0.12.1 24
[R1-Serial4/0/0]quit
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 10.0.13.1 24
其他路由器配置ip地址类似,就不重复了。
二、测试连通性
[R1]ping 10.0.12.2
PING 10.0.12.2: 56 data bytes, press CTRL_C to break
Reply from 10.0.12.2: bytes=56 Sequence=1 ttl=255 time=20 ms
Reply from 10.0.12.2: bytes=56 Sequence=2 ttl=255 time=10 ms
Reply from 10.0.12.2: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 10.0.12.2: bytes=56 Sequence=4 ttl=255 time=10 ms
Reply from 10.0.12.2: bytes=56 Sequence=5 ttl=255 time=10 ms
--- 10.0.12.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/14/20 ms
[R1]ping 10.0.13.3
PING 10.0.13.3: 56 data bytes, press CTRL_C to break
Reply from 10.0.13.3: bytes=56 Sequence=1 ttl=255 time=10 ms
Reply from 10.0.13.3: bytes=56 Sequence=2 ttl=255 time=10 ms
Reply from 10.0.13.3: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 10.0.13.3: bytes=56 Sequence=4 ttl=255 time=10 ms
Reply from 10.0.13.3: bytes=56 Sequence=5 ttl=255 time=10 ms
--- 10.0.13.3 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/12/20 ms
[R2]ping 10.0.23.3
PING 10.0.23.3: 56 data bytes, press CTRL_C to break
Reply from 10.0.23.3: bytes=56 Sequence=1 ttl=255 time=20 ms
Reply from 10.0.23.3: bytes=56 Sequence=2 ttl=255 time=10 ms
Reply from 10.0.23.3: bytes=56 Sequence=3 ttl=255 time=10 ms
Reply from 10.0.23.3: bytes=56 Sequence=4 ttl=255 time=20 ms
Reply from 10.0.23.3: bytes=56 Sequence=5 ttl=255 time=10 ms
--- 10.0.23.3 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/14/20 ms
测试R2到达10.0.3.3和10.0.13.3连通性
[R2]ping 10.0.3.3
PING 10.0.3.3: 56 data bytes, press CTRL_C to break
Request time out
Request time out
Request time out
Request time out
Request time out
--- 10.0.3.3 ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
[R2]ping 10.0.13.3
PING 10.0.13.3: 56 data bytes, press CTRL_C to break
Request time out
Request time out
Request time out
Request time out
Request time out
--- 10.0.13.3 ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
不能连通。
[R2]display ip routing
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 15 Routes : 15
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.0.2.0/24 Direct 0 0 D 10.0.2.2 LoopBack0
10.0.2.2/32 Direct 0 0 D 127.0.0.1 LoopBack0
10.0.2.255/32 Direct 0 0 D 127.0.0.1 LoopBack0
10.0.12.0/24 Direct 0 0 D 10.0.12.2 Serial4/0/0
10.0.12.1/32 Direct 0 0 D 10.0.12.1 Serial4/0/0
10.0.12.2/32 Direct 0 0 D 127.0.0.1 Serial4/0/0
10.0.12.255/32 Direct 0 0 D 127.0.0.1 Serial4/0/0
10.0.23.0/24 Direct 0 0 D 10.0.23.2 Serial4/0/1
10.0.23.2/32 Direct 0 0 D 127.0.0.1 Serial4/0/1
10.0.23.3/32 Direct 0 0 D 10.0.23.3 Serial4/0/1
10.0.23.255/32 Direct 0 0 D 127.0.0.1 Serial4/0/1
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
在R2路由表上都没有去往目的地址的路由,所以不能ping通
三、在R2上配置静态路由
配置目的网络10.0.13.0/24和10.0.3.0/24的静态路由,吓一跳信息设置为R3的接口地址10.0.23.3,默认静态路由优先级为60,无需额外配置路由优先级信息。
[R2]ip route-static 10.0.13.0 24 10.0.23.3
[R2]ip route-static 10.0.3.0 24 10.0.23.3
四、配置备用静态路由
如果R2与R3之间链路出现故障的话,会造成通信无法进行,为了避免该情况出现,(从拓扑可以看出)R2与R3回话可以通过R1来进行。网络正常的情况下,备份路由不起作用。
配置静态路由时重要一点事配置优先级(静态默认60),在这里我们定义为100
1.将10.0.12.0与10.0.3.0网段先打通
[R1]ip route-static 10.0.3.0 24 10.0.13.3
[R3]ip route-static 10.0.12.0 24 10.0.13.1
2.再配置路由和优先级
[R2] ip route-static 10.0.3.0 24 s4/0/0 preference 100
[R2] ip route-static 10.0.13.0 24 s4/0/0 preference 100
3.验证配置信息
<1>链路不出问题
<2>R2与R3链路出现故障(将s4/0/1关闭shutdown)
备份链路起作用
[R2-Serial4/0/1]ping 10.0.3.3
PING 10.0.3.3: 56 data bytes, press CTRL_C to break
Reply from 10.0.3.3: bytes=56 Sequence=1 ttl=254 time=210 ms
Reply from 10.0.3.3: bytes=56 Sequence=2 ttl=254 time=20 ms
Reply from 10.0.3.3: bytes=56 Sequence=3 ttl=254 time=20 ms
Reply from 10.0.3.3: bytes=56 Sequence=4 ttl=254 time=30 ms
Reply from 10.0.3.3: bytes=56 Sequence=5 ttl=254 time=20 ms
--- 10.0.3.3 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/60/210 ms
使用tracert跟踪路由
[R2]tracert 10.0.3.3
traceroute to 10.0.3.3(10.0.3.3), max hops: 30 ,packet length: 40,press CTRL_C to break
1 10.0.12.1 30 ms 10 ms 10 ms
2 10.0.13.3 20 ms 20 ms 20 ms
五、配置缺省路由(默认路由)
在 R2设备上打开之前关闭的接口
[R2]int s4/0/1
[R2-Serial4/0/1]undo shut
测试R1到R3的连通性
由于R1缺少到达地址10.0.23.3的路由信息,所以不能连通。
现在在R1上定义默认路由,实现网络通信
[R1]ip route-static 0.0.0.0 0.0.0.0 10.0.13.3
测试连通性
六、备用默认路由
如果说R1与R3链路出现故障的话,R1也可以通过R2与地址10.0.23.3以及10.0.3.3通信。
但是默认情况下R1并不知道这条链路的存在,所以可以配置备用默认路由
[R1]ip route-static 0.0.0.0 0.0.0.0 10.0.12.2 preference 100 ---默认备份路由
[R3]ip route-static 10.0.12.0 24 10.0.23.2 preference 100 ---静态备份路由
七、验证备用默认路由
1.正常情况下的R1路由条目
2.R1接口GE0/0/0shutdown下路由条目,备用已启用
使用tracert测试
八、华为路由各路由协议的默认优先级