拓扑图
实现结果:
1.pc1访问pc345走上面R1,R2,R2实现备份21.1.1.0/24,实现备份pc3456访问pc12走下面的R3,R4并实现等价路由,尽量减少路由条目,全网可达
2.R7代表运行商,所有pc均可访问
第一步:所有的路由器配地址:在这里举例R2路由器g0/0/0端口
[r2]interface g0/0/0
[r2-GigabitEthernet0/0/0]ip add
[r2-GigabitEthernet0/0/0]ip address 16.1.1.2 24
Jul 22 2022 08:08:05-08:00 r2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[r2-GigabitEthernet0/0/0]quit
第二步:配PC地址,用dhcp配置:在这里举例R1路由器
[r1]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[r1]ip pool 1
Info: It's successful to create an IP address pool.
[r1-ip-pool-1]network 172.16.1.0 mask 255.255.255.0
[r1-ip-pool-1]gateway-list 172.16.1.1
[r1-ip-pool-1]dns-list 8.8.8.8 114.114.114.114
[r1-ip-pool-1]quit
[r1]interface g0/0/0
[r1-GigabitEthernet0/0/0]dhcp select global
[r1-GigabitEthernet0/0/0]
第三:查看路由表,下一跳写法进行静态路由配置:在这里举例R2路由器
在此处通过优先级设置实现24.1.1.0路径备份
[r2]ip route-static 24.1.1.0 24 12.1.1.2
[r2]ip route-static 45.1.1.0 24 12.1.1.2
[r2]ip route-static 192.168.0.0 22 12.1.1.2
[r2]ip route-static 172.16.1.0 24 16.1.1.1
[r2]ip route-static 43.1.1.0 24 16.1.1.1
[r2]ip route-static 34.1.1.0 24 16.1.1.1
[r2]ip route-static 24.1.1.0 24 21.1.1.2 preference 61
[r2]ip route-static 45.1.1.0 24 21.1.1.2 preference 61
[r2]ip route-static 192.168.0.0 22 21.1.1.2 preference 61
第四:每个路由器下发缺省路由,最终实现外网访问
[r1]ip route-static 0.0.0.0 0 67.1.1.2[r2]ip route-static 0.0.0.0 0 16.1.1.1[r3]ip route-static 0.0.0.0 0 12.1.1.1[r3]ip route-static 0.0.0.0 0 21.1.1.1 preference 61[r4]ip route-static 0.0.0.0 0 13.1.1.1[r5]ip route-static 0.0.0.0 0 24.1.1.1[r5]ip route-static 0.0.0.0 0 34.1.1.1[r5]ip route-static 0.0.0.0 0 43.1.1.1[r6]ip route-static 0.0.0.0 0 45.1.1.1
第五:查看路由器静态配置所有地址是否全部完成,以路由器1为例:
<r1>display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: PublicDestinations : 21 Routes : 21 Destination/Mask Proto Pre Cost Flags NextHop Interface12.1.1.0/24 Static 60 0 RD 16.1.1.2 GigabitEthernet
0/0/113.1.1.0/24 Static 60 0 RD 16.1.1.2 GigabitEthernet
0/0/116.1.1.0/24 Direct 0 0 D 16.1.1.1 GigabitEthernet
0/0/116.1.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/116.1.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/121.1.1.0/24 Static 60 0 RD 16.1.1.2 GigabitEthernet
0/0/124.1.1.0/24 Static 60 0 RD 16.1.1.2 GigabitEthernet
0/0/134.1.1.0/24 Static 60 0 RD 16.1.1.2 GigabitEthernet
0/0/143.1.1.0/24 Static 60 0 RD 16.1.1.2 GigabitEthernet
0/0/145.1.1.0/24 Static 60 0 RD 16.1.1.2 GigabitEthernet
0/0/167.1.1.0/24 Direct 0 0 D 67.1.1.1 GigabitEthernet
0/0/267.1.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/267.1.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/2127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0127.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 InLoopBack0172.16.1.0/24 Direct 0 0 D 172.16.1.1 GigabitEthernet
0/0/0172.16.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0172.16.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0192.168.0.0/22 Static 60 0 RD 16.1.1.2 GigabitEthernet
0/0/1
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
第六:测试
最后将AR2所有代码展示如下:
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname r2
配IP地址
[r2]interface g0/0/0
[r2-GigabitEthernet0/0/0]ip address 16.1.1.2 24
Jul 22 2022 08:08:05-08:00 r2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[r2-GigabitEthernet0/0/0]quit
[r2]interface g0/0/1
[r2-GigabitEthernet0/0/1]ip address 12.1.1.1 24
Jul 22 2022 08:08:42-08:00 r2 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[r2-GigabitEthernet0/0/1]quit
[r2]interface g0/0/2
[r2-GigabitEthernet0/0/2]ip address 21.1.1.1 24
Jul 22 2022 08:09:19-08:00 r2 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP
on the interface GigabitEthernet0/0/2 has entered the UP state.
[r2-GigabitEthernet0/0/2]quit
[r2]interface g4/0/0
[r2-GigabitEthernet4/0/0]ip address 13.1.1.1 24
Jul 22 2022 08:09:58-08:00 r2 %%01IFNET/4/LINK_STATE(l)[3]:The line protocol IP
on the interface GigabitEthernet4/0/0 has entered the UP state.
静态路由配置
[r2]ip route-static 24.1.1.0 24 12.1.1.2
[r2]ip route-static 45.1.1.0 24 12.1.1.2
[r2]ip route-static 192.168.0.0 22 12.1.1.2
[r2]ip route-static 172.16.1.0 24 16.1.1.1
[r2]ip route-static 43.1.1.0 24 16.1.1.1
[r2]ip route-static 34.1.1.0 24 16.1.1.1
[r2]quit
<r2>saveThe current configuration will be written to the device. Are you sure to continue? (y/n)[n]:yIt will take several minutes to save configuration file, please wait.........Configuration file had been saved successfullyNote: The configuration file will take effect after being activated
[r2]ip route-static 0.0.0.0 0 67.1.1.1
[r2]ip route-static 24.1.1.0 24 21.1.1.2 preference 61
[r2]ip route-static 45.1.1.0 24 21.1.1.2 preference 61
[r2]ip route-static 192.168.0.0 22 21.1.1.2 preference 61 实现备份
[r2]quit
[r2]ip route-static 0.0.0.0 0 16.1.1.1 缺省路由