拓扑图

适合网络要求比较高的小网络,线路故障自动切换。

1、路由器1基本配置部分:

The device is running!
system-view #进入系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname AR1 #修改设备名称
[AR1]interface GigabitEthernet 0/0/0 #进入端口0/0/0
[AR1-GigabitEthernet0/0/0]ip address 10.11.12.100 24 #配置IP地址及子网掩码
[AR1-GigabitEthernet0/0/0]ping 10.11.12.1 #检测连通性
PING 10.11.12.1: 56 data bytes, press CTRL_C to break
Reply from 10.11.12.1: bytes=56 Sequence=1 ttl=128 time=80 ms
Reply from 10.11.12.1: bytes=56 Sequence=2 ttl=128 time=10 ms
Reply from 10.11.12.1: bytes=56 Sequence=3 ttl=128 time=20 ms
Reply from 10.11.12.1: bytes=56 Sequence=4 ttl=128 time=20 ms
Reply from 10.11.12.1: bytes=56 Sequence=5 ttl=128 time=20 ms
--- 10.11.12.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/30/80 ms
[AR1-GigabitEthernet0/0/0]quit #退出端口
[AR1]interface GigabitEthernet 0/0/1 #进入接口0/0/1
[AR1-GigabitEthernet0/0/1]ip address 10.10.10.1 24 #配置IP地址及子网掩码
[AR1-GigabitEthernet0/0/0]quit #退出端口
[AR1]acl 2001 #创建acl 2001
[AR1-acl-basic-2001]rule permit source 10.10.10.0 0.0.0.255 #配置匹配IP地址及长度
[AR1-acl-basic-2001]quit #退出acl 2001
[AR1]interface GigabitEthernet 0/0/0 #进入端口0/0/0
[AR1-GigabitEthernet0/0/0]nat outbound 2001 #配置nat出方向匹配acl2001
[AR1-GigabitEthernet0/0/0]quit #退出端口
[AR1]ip route-static 0.0.0.0 0.0.0.0 10.11.12.1 #新建默认路由执行外网网关
[AR1]ping 114.114.114.114 #检测网络连通性
PING 114.114.114.114: 56 data bytes, press CTRL_C to break
Reply from 114.114.114.114: bytes=56 Sequence=1 ttl=128 time=70 ms
Reply from 114.114.114.114: bytes=56 Sequence=2 ttl=128 time=20 ms
Reply from 114.114.114.114: bytes=56 Sequence=3 ttl=128 time=10 ms
Reply from 114.114.114.114: bytes=56 Sequence=4 ttl=128 time=10 ms
Reply from 114.114.114.114: bytes=56 Sequence=5 ttl=128 time=20 ms
--- 114.114.114.114 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/26/70 ms

2、路由器2基本配置部分:

The device is running!
system-view #进入系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname AR2 #修改设备名称
[AR2]interface GigabitEthernet 0/0/0 #进入端口0/0/0
[AR2-GigabitEthernet0/0/0]ip address 10.11.12.101 24 #配置IP地址及子网掩码
[AR2-GigabitEthernet0/0/0]ping 10.11.12.1 #检测连通性
PING 10.11.12.1: 56 data bytes, press CTRL_C to break
Reply from 10.11.12.1: bytes=56 Sequence=1 ttl=128 time=80 ms
Reply from 10.11.12.1: bytes=56 Sequence=2 ttl=128 time=10 ms
Reply from 10.11.12.1: bytes=56 Sequence=3 ttl=128 time=10 ms
Reply from 10.11.12.1: bytes=56 Sequence=4 ttl=128 time=10 ms
Reply from 10.11.12.1: bytes=56 Sequence=5 ttl=128 time=10 ms
--- 10.11.12.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/24/80 ms
[AR2-GigabitEthernet0/0/0]quit #退出端口
[AR2]interface GigabitEthernet 0/0/1 #进入端口0/0/1
[AR2-GigabitEthernet0/0/1]ip address 10.10.20.1 24 #皮遏制IP地址及子网掩码
[AR2-GigabitEthernet0/0/1]quit #退出端口
[AR2]acl 2001 #创建acl 2001
[AR2-acl-basic-2001]rule permit source 10.10.20.0 0.0.0.255 #配置匹配IP地址及子网长度
[AR2-acl-basic-2001]quit #退出端口
[AR2]interface GigabitEthernet 0/0/0 #进入端口0/0/0
[AR2-GigabitEthernet0/0/0]nat outbound 2001 #配置nat出方向匹配acl2001
[AR2-GigabitEthernet0/0/0]quit #退出端口
[AR2]ip route-static 0.0.0.0 0.0.0.0 10.11.12.1 #新建默认路由指向外网网关
[AR2]ping 114.114.114.114 #检测连通性
PING 114.114.114.114: 56 data bytes, press CTRL_C to break
Reply from 114.114.114.114: bytes=56 Sequence=1 ttl=128 time=20 ms
Reply from 114.114.114.114: bytes=56 Sequence=2 ttl=128 time=30 ms
Reply from 114.114.114.114: bytes=56 Sequence=3 ttl=128 time=20 ms
Reply from 114.114.114.114: bytes=56 Sequence=4 ttl=128 time=20 ms
Reply from 114.114.114.114: bytes=56 Sequence=5 ttl=128 time=20 ms
--- 114.114.114.114 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/22/30 ms

3、路由器3基本配置:

The device is running!
system-view #进入系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname AR3 #修改设备名称
[AR3]dhcp enable #开启dhcp
Info: The operation may take a few seconds. Please wait for a moment.done.
[AR3]interface GigabitEthernet 2/0/0 #进入端口2/0/0/
[AR3-GigabitEthernet2/0/0]ip address 192.168.1.254 24 #配置IP地址及子网掩码
[AR3-GigabitEthernet2/0/0]dhcp select interface #dhcp模式选择接口
[AR3-GigabitEthernet2/0/0]dhcp server dns-list 114.114.114.114 #配置dns地址
[AR3-GigabitEthernet2/0/0]quit #退出端口
[AR3]interface GigabitEthernet 0/0/0 #进入端口0/0/0
[AR3-GigabitEthernet0/0/0]ip address 10.10.10.2 24 #配置IP地址及子网掩码
[AR3-GigabitEthernet0/0/0]ping 10.10.10.1 #检测连通性
PING 10.10.10.1: 56 data bytes, press CTRL_C to break
Reply from 10.10.10.1: bytes=56 Sequence=1 ttl=255 time=130 ms
Reply from 10.10.10.1: bytes=56 Sequence=2 ttl=255 time=30 ms
Reply from 10.10.10.1: bytes=56 Sequence=3 ttl=255 time=40 ms
Reply from 10.10.10.1: bytes=56 Sequence=4 ttl=255 time=30 ms
Reply from 10.10.10.1: bytes=56 Sequence=5 ttl=255 time=20 ms
--- 10.10.10.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/50/130 ms
[AR3-GigabitEthernet0/0/0]quit #退出端口
[AR3]interface GigabitEthernet 0/0/1 #进入端口0/0/1
[AR3-GigabitEthernet0/0/1]ip address 10.10.20.2 24 #配置IP地址及子网掩码
[AR3-GigabitEthernet0/0/1]ping 10.10.20.1 #检测连通性
PING 10.10.20.1: 56 data bytes, press CTRL_C to break
Reply from 10.10.20.1: bytes=56 Sequence=1 ttl=255 time=100 ms
Reply from 10.10.20.1: bytes=56 Sequence=2 ttl=255 time=10 ms
Reply from 10.10.20.1: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 10.10.20.1: bytes=56 Sequence=4 ttl=255 time=20 ms
Reply from 10.10.20.1: bytes=56 Sequence=5 ttl=255 time=30 ms
--- 10.10.20.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/36/100 ms
[AR3-GigabitEthernet0/0/1]quit #退出端口
[AR3]ip route-static 0.0.0.0 0.0.0.0 10.10.10.1 #新建默认路由指向AR1
[AR3]ip route-static 0.0.0.0 0.0.0.0 10.10.20.1 preference 100 #新建默认路由指向AR2,优先级为100

查看AR3的路由表

[AR3]display ip routing-table #查看ip路由表
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 14 Routes : 14
Destination/Mask Proto Pre Cost Flags NextHop Interface
0.0.0.0/0 Static 60 0 RD 10.10.10.1 GigabitEthernet0/0/0
10.10.10.0/24 Direct 0 0 D 10.10.10.2 GigabitEthernet0/0/0
10.10.10.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/0
10.10.10.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/0
10.10.20.0/24 Direct 0 0 D 10.10.20.2 GigabitEthernet0/0/1
10.10.20.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/1
10.10.20.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/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
192.168.1.0/24 Direct 0 0 D 192.168.1.254 GigabitEthernet
2/0/0
192.168.1.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
2/0/0
192.168.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
2/0/0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0

4、创建AR1与AR2和AR3的返程路由

AR1的回程路由

[AR1]ip route-static 192.168.1.0 255.255.255.0 10.10.10.2 #新建192.168.1.0路由指向AR3的IP地址
[AR1]ping 192.168.1.254 #检测连通性
PING 192.168.1.253: 56 data bytes, press CTRL_C to break
Request time out
Reply from 192.168.1.254: bytes=56 Sequence=2 ttl=127 time=20 ms
Reply from 192.168.1.254: bytes=56 Sequence=3 ttl=127 time=20 ms
Reply from 192.168.1.254: bytes=56 Sequence=4 ttl=127 time=20 ms
Reply from 192.168.1.254: bytes=56 Sequence=5 ttl=127 time=20 ms
--- 192.168.1.253 ping statistics ---
5 packet(s) transmitted
4 packet(s) received
20.00% packet loss
round-trip min/avg/max = 20/20/20 ms

AR2的回程路由

[AR2]ip route-static 192.168.1.0 255.255.255.0 10.10.20.2 #新建192.168.1.0路由指向AR3的IP地址
[AR2]ping 192.168.1.254 #检测连通性
PING 192.168.1.253: 56 data bytes, press CTRL_C to break
Reply from 192.168.1.254: bytes=56 Sequence=1 ttl=127 time=20 ms
Reply from 192.168.1.254: bytes=56 Sequence=2 ttl=127 time=20 ms
Reply from 192.168.1.254: bytes=56 Sequence=3 ttl=127 time=20 ms
Reply from 192.168.1.254: bytes=56 Sequence=4 ttl=127 time=20 ms
Reply from 192.168.1.254: bytes=56 Sequence=5 ttl=127 time=30 ms
--- 192.168.1.253 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/22/30 ms

5、检测路由状态

PC自动获取到的IP地址及dns

路由检测:检测路由从优先级小的线路1(AR1)出去了

路由1

模拟线路1故障:

[AR3]interface GigabitEthernet 0/0/0 进入端口0/0/0
[AR3-GigabitEthernet0/0/0]shutdown #关闭端口,模拟线路故障

路由检测:检测路由从线路2(AR2)出去了

路由2

#谢谢#

#华为# #华为路由器##ENSP##策略路由# #路由器##双链路#