拓扑图(含IP规划)
配置任务
按照拓扑图要求配置IP地址,手动添加构建路由表,并在路由器R1和R2间实现静态路由的负载分担(到相同目的地址的下一跳不同,但优先级相同;到目的地的流量将均匀分布),在路由器R2和R3间实现静态路由的主备路由备份(到相同目的地址的下一跳和优先级都不同,优先级高的为主,低的为备),最终实现PC1和PC2的互相通信。配置工具
华为网络设备仿真平台eNSP
配置步骤(含完整指令)
首先,配置主机PC1、PC2的IP信息很简单(留意网关就好),比如PC1就这样:
然后,需要配置的是R1、R2、R3、R4的各个端口所分配的IP地址,以R1为例,需要配置的有Eth0/0/0(192.168.1.2/24)、Eth0/0/1(10.1.1.1/30)、G0/0/0(10.1.2.1/30)这三个端口。
sys #R1
Enter system view, return user view with Ctrl+Z.
[Huawei]int Eth0/0/0
[Huawei-Ethernet0/0/0]ip address 192.168.1.2 24
[Huawei-Ethernet0/0/0]
Jul 25 2019 17:11:56-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface Ethernet0/0/0 has entered the UP state.
Jul 25 2019 17:12:02-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 1, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-Ethernet0/0/0]q
[Huawei]int Eth0/0/1
[Huawei-Ethernet0/0/1]ip address 10.1.1.1 30
[Huawei-Ethernet0/0/1]
Jul 25 2019 17:14:34-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface Ethernet0/0/1 has entered the UP state.
Jul 25 2019 17:14:42-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 2, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-Ethernet0/0/1]q
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 10.1.2.1 30
[Huawei-GigabitEthernet0/0/0]
Jul 25 2019 17:21:12-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
Jul 25 2019 17:21:13-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 3, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-GigabitEthernet0/0/0]q
[Huawei]display ip routing-table # 查询一下当前的路由表中有哪些表项
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 8 Routes : 8
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.1.1.0/30 Direct 0 0 D 10.1.1.1 Ethernet0/0/1
10.1.1.1/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/1
10.1.2.0/30 Direct 0 0 D 10.1.2.1 GigabitEthernet
0/0/0
10.1.2.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
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
192.168.1.0/24 Direct 0 0 D 192.168.1.2 Ethernet0/0/0
192.168.1.2/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/0
类似地方法不断操作,可以完成R1、R1、R2、R3、R4的各个端口IP地址的配置。
sys #R2
Enter system view, return user view with Ctrl+Z.
[Huawei]int eth0/0/0
[Huawei-Ethernet0/0/0]ip address 10.1.1.2 30
[Huawei-Ethernet0/0/0]
Jul 25 2019 18:28:03-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface Ethernet0/0/0 has entered the UP state.
Jul 25 2019 18:28:05-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 1, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-Ethernet0/0/0]q
[Huawei]int eth0/0/1
[Huawei-Ethernet0/0/1]ip address 10.1.2.2 30
[Huawei-Ethernet0/0/1]
Jul 25 2019 18:28:32-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface Ethernet0/0/1 has entered the UP state.
Jul 25 2019 18:28:35-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 2, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-Ethernet0/0/1]q
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 10.1.3.1 30
[Huawei-GigabitEthernet0/0/0]
Jul 25 2019 18:28:52-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
Jul 25 2019 18:28:55-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 3, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-GigabitEthernet0/0/0]q
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 10.1.4.1 30
[Huawei-GigabitEthernet0/0/1]
Jul 25 2019 18:29:09-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[3]:The line protocol IP on the interface GigabitEthernet0/0/1 has entered the UP state.
Jul 25 2019 18:29:15-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 4, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-GigabitEthernet0/0/1]q
[Huawei]
sys #R3
Enter system view, return user view with Ctrl+Z.
[Huawei]int eth0/0/0
[Huawei-Ethernet0/0/0]ip address 10.1.3.2 30
[Huawei-Ethernet0/0/0]
Jul 25 2019 18:31:29-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface Ethernet0/0/0 has entered the UP state.
Jul 25 2019 18:31:35-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 1, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-Ethernet0/0/0]q
[Huawei]int eth0/0/1
[Huawei-Ethernet0/0/1]ip address 10.1.4.2 30
[Huawei-Ethernet0/0/1]
Jul 25 2019 18:31:59-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface Ethernet0/0/1 has entered the UP state.
Jul 25 2019 18:32:05-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 2, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-Ethernet0/0/1]q
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 10.1.5.1 30
[Huawei-GigabitEthernet0/0/0]
Jul 25 2019 18:32:27-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
Jul 25 2019 18:32:35-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 3, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-GigabitEthernet0/0/0]q
[Huawei]
sys #R4
Enter system view, return user view with Ctrl+Z.
[Huawei]int Eth0/0/0
[Huawei-Ethernet0/0/0]ip address 10.1.5.2 30
[Huawei-Ethernet0/0/0]
Jul 25 2019 18:33:47-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface Ethernet0/0/0 has entered the UP state.
Jul 25 2019 18:33:55-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 1, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-Ethernet0/0/0]q
[Huawei]int Eth0/0/1
[Huawei-Ethernet0/0/1]ip address 192.168.2.2 24
[Huawei-Ethernet0/0/1]
Jul 25 2019 18:34:13-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP on the interface Ethernet0/0/1 has entered the UP state.
Jul 25 2019 18:34:15-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 2, the change loop count is 0, and the maximum number of records is 4095.
[Huawei-Ethernet0/0/1]q
[Huawei]
接下来,需要在各个路由器上添加路由表信息,配置任务只需要我们“打通”PC1和PC2之间的数据通信,那么这里的会我偷个懒,用至少的配置步骤添加路由,过程如下:
sys #R1
Enter system view, return user view with Ctrl+Z.
[Huawei]ip route-static 192.168.2.1 24 10.1.2.2 #添加两条静态路由 负载分担
Info: The destination address and mask of the configured static route mismatched
, and the static route 192.168.2.0/24 was generated.
Jul 25 2019 18:41:35-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 4, the change loop count is 0, and the maximum number of records is 4095.
[Huawei]ip route-static 192.168.2.1 24 10.1.1.2 #添加两条静态路由 负载分担
Info: The destination address and mask of the configured static route mismatched
, and the static route 192.168.2.0/24 was generated.
Jul 25 2019 18:42:25-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 5, the change loop count is 0, and the maximum number of records is 4095.
[Huawei]
sys #R2
Enter system view, return user view with Ctrl+Z.
[Huawei]ip route-static 192.168.2.1 24 10.1.3.2 preference 100 #添加主/备静态路由 备
Info: The destination address and mask of the configured static route mismatched
, and the static route 192.168.2.0/24 was generated.
Jul 25 2019 18:47:26-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 5, the change loop count is 0, and the maximum number of records is 4095.
[Huawei]ip route-static 192.168.2.1 24 10.1.4.2 preference 60 #添加主/备静态路由 主
Info: The destination address and mask of the configured static route mismatched
, and the static route 192.168.2.0/24 was generated.
Jul 25 2019 18:51:26-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 6, the change loop count is 0, and the maximum number of records is 4095.
[Huawei]ip route-static 192.168.1.1 24 10.1.1.1 #添加两条静态路由 负载分担
Info: The destination address and mask of the configured static route mismatched
, and the static route 192.168.1.0/24 was generated.
Jul 25 2019 18:53:16-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 7, the change loop count is 0, and the maximum number of records is 4095.
[Huawei]ip route-static 192.168.1.1 24 10.1.2.1 #添加两条静态路由 负载分担
Info: The destination address and mask of the configured static route mismatched
, and the static route 192.168.1.0/24 was generated.
Jul 25 2019 18:53:36-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 8, the change loop count is 0, and the maximum number of records is 4095.
[Huawei]
sys #R3
Enter system view, return user view with Ctrl+Z.
[Huawei]ip route-static 192.168.2.1 24 10.1.5.2 #添加一条静态路由
Info: The destination address and mask of the configured static route mismatched
, and the static route 192.168.2.0/24 was generated.
Jul 25 2019 18:57:46-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 4, the change loop count is 0, and the maximum number of records is 4095.
[Huawei]ip route-static 192.168.1.1 24 10.1.3.1 preference 100 #添加主/备静态路由 备
Info: The destination address and mask of the configured static route mismatched
, and the static route 192.168.1.0/24 was generated.
Jul 25 2019 18:58:26-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 5, the change loop count is 0, and the maximum number of records is 4095.
[Huawei]ip route-static 192.168.1.1 24 10.1.4.1 preference 60 #添加主/备静态路由 主
Info: The destination address and mask of the configured static route mismatched
, and the static route 192.168.1.0/24 was generated.
Jul 25 2019 18:58:56-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 6, the change loop count is 0, and the maximum number of records is 4095.
[Huawei]
sys #R4
Enter system view, return user view with Ctrl+Z.
[Huawei]ip route-static 192.168.1.1 24 10.1.5.1 #添加一条静态路由
Info: The destination address and mask of the configured static route mismatched
, and the static route 192.168.1.0/24 was generated.
[Huawei]
Jul 25 2019 19:01:36-08:00 Huawei DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.191.3.1 configurations have been changed. The current change number is 3, the change loop count is 0, and the maximum number of records is 4095.
[Huawei]
经过上面的路由配置,我们的主机PC1和PC2应当可以就互相通信了!
结果验证
- ping验证(PC1 上 ping PC2)
PC>ping 192.168.2.1
Ping 192.168.2.1: 32 data bytes, Press Ctrl_C to break
From 192.168.2.1: bytes=32 seq=1 ttl=124 time=219 ms
From 192.168.2.1: bytes=32 seq=2 ttl=124 time=156 ms
From 192.168.2.1: bytes=32 seq=3 ttl=124 time=187 ms
From 192.168.2.1: bytes=32 seq=4 ttl=124 time=187 ms
From 192.168.2.1: bytes=32 seq=5 ttl=124 time=187 ms
--- 192.168.2.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 156/187/219 ms
- tracert验证
很显然,这同我们所期望的路由转发路径是一致的!主要看R2-R3这一段转发,我们配置了主备路由备份,转发路径必须沿着R2的GE0/0/1(10.1.4.1/30) -> R3的Eth0/0/1(10.1.4.2/30) 转发!
PC>tracert 192.168.2.1
traceroute to 192.168.2.1, 8 hops max
(ICMP), press Ctrl+C to stop
1 192.168.1.2 15 ms 31 ms 32 ms
2 10.1.2.2 93 ms 79 ms 62 ms
3 10.1.4.2 94 ms 94 ms 125 ms
4 10.1.5.2 140 ms 125 ms 125 ms
5 *192.168.2.1 156 ms 188 ms
- 查看路由表情况
[Huawei]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 12 Routes : 13
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.1.1.0/30 Direct 0 0 D 10.1.1.2 Ethernet0/0/0
10.1.1.2/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/0
10.1.2.0/30 Direct 0 0 D 10.1.2.2 Ethernet0/0/1
10.1.2.2/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/1
10.1.3.0/30 Direct 0 0 D 10.1.3.1 GigabitEthernet
0/0/0
10.1.3.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
10.1.4.0/30 Direct 0 0 D 10.1.4.1 GigabitEthernet
0/0/1
10.1.4.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/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
192.168.1.0/24 Static 60 0 RD 10.1.1.1 Ethernet0/0/0
Static 60 0 RD 10.1.2.1 Ethernet0/0/1
192.168.2.0/24 Static 60 0 RD 10.1.4.2 GigabitEthernet
0/0/1
这里其实有一个问题,我们在路由器R2上给目的地址192.168.1.1/24
即主机PC1定义了两条静态路由负载分担,这在上面的路由表中有体现出来,没什么问题。但同时我们也有在给目的地址192.168.2.1/24
即主机PC2定义了两条主/备静态路由(优先级不同),不过在路由表中没有这样的两条记录。
其实,这很好理解,对于这种主/备路由备份模式,由于我们给“主用路由表项”定义的优先级始终最高,所以它应当是处于Active状态的,根本轮不到那条“备用路由表项”,因此它的状态应当是Inactive的!
那么,既然display ip routing-table
这条命令无法查看到那条Inactive状态的路由表项,我们就得另想办法,这里介绍这样几条指令——display ip routing-table protocol static
,display ip routing-table verbose
以及display current-configuration
!
-
display ip routing-table protocol static
这条指令表示查看协议类型为static的所有路由表项(包括Inactive状态的),类似的,查看协议类型为ospf的所有路由表项,就是用display ip routing-table protocol ospf
。 -
display ip routing-table verbose
这条指令可以查看路由表的详细信息(也就是包括所有路由表项)。 -
display current-configuration
显示当前配置信息。
参考文献
- 《计算机网络》谢希仁. pdf版
- 多区域OSPF动态路由协议的配置
- 某些数通基本知识梳理