题目
步骤
- 分配ip网段
已图所示有6个实体网段和R1到R4的虚拟接口的8个网段,一共有14个网段。题中是以192.168.1.0/24网段进行划分。所以从主机位抢走4位作为网络位,即网络位为28,主机位为4.(就不具体细讲网段划分):- 192.168.1.0/28
- 192.168.1.16/28
- 192.168.1.32/28
- 192.168.1.48/28
- 192.168.1.64/28
- 192.168.1.80/28
- 192.168.1.96/28
- 192.168.1.112/28
- 192.168.1.128/28
- 192.168.1.144/28
- 192.168.1.160/28
- 192.168.1.176/28
- 192.168.1.192/28
- 192.168.1.208/28
如图所示:
- 配置网关
- 配置AR1路由
<Huawei>system-view //进入系统视图
[Huawei]sysname AR1 //更改名字为AR1
[AR1]interface g 0/0/0 //进入接口
[AR1-GigabitEthernet0/0/0]ip address 192.168.1.33 28 //配置网关ip
[AR1-GigabitEthernet0/0/0]quit //退出接口
[AR1]interface g 0/0/1
[AR1-GigabitEthernet0/0/1]ip address 192.168.1.49 28
[AR1-GigabitEthernet0/0/1]quit
[AR1]interface LoopBack 0 //进入环回接口
[AR1-LoopBack0]ip address 192.168.1.1 28 //配置环回网关ip
[AR1-LoopBack0]quit
[AR1]interface LoopBack 1
[AR1-LoopBack1]ip address 192.168.1.17 28
[AR1-LoopBack1]quit
[AR1]quit //返回用户视图
< AR1 >save
The current configuration will be written to the device.
Are you sure to continue? (y/n)[n]:y //确认保存
配置AR2路由
<Huawei>system-view
[Huawei]sysname AR2
[AR2]interface GigabitEthernet 0/0/1
[AR2-GigabitEthernet0/0/1]ip address 192.168.1.34 28
[AR2-GigabitEthernet0/0/1]q //quit的简写
[AR2]interface GigabitEthernet 0/0/0
[AR2-GigabitEthernet0/0/0]ip address 192.168.1.145 28
[AR2-GigabitEthernet0/0/0]q
[AR2]interface LoopBack 0
[AR2-LoopBack0]ip address 192.168.1.113 28
[AR2-LoopBack0]q
[AR2]interface LoopBack 1
[AR2-LoopBack1]ip address 192.168.1.129 28
[AR2-LoopBack1]q
[AR2] //ctrl+z
<AR2>save
The current configuration will be written to the device.
Are you sure to continue? (y/n)[n]:y
配置AR3路由
<Huawei>system-view
[Huawei]sysname AR3
[AR3]interface GigabitEthernet 0/0/1
[AR3-GigabitEthernet0/0/1]ip address 192.168.1.50 28
[AR3-GigabitEthernet0/0/1]q
[AR3]interface g 0/0/0
[AR3-GigabitEthernet0/0/0]ip address 192.168.1.97 28
[AR3-GigabitEthernet0/0/0]q
[AR3]interface LoopBack 0
[AR3-LoopBack0]ip address 192.168.1.65 28
[AR3-LoopBack0]q
[AR3]interface LoopBack 1
[AR3-LoopBack1]ip address 192.168.1.81 28
[AR3-LoopBack1]q
[AR3]
<AR3>save
The current configuration will be written to the device.
Are you sure to continue? (y/n)[n]:y
配置R1路由
<Huawei>system-view
[Huawei]sysname R1
[R1]interface Ethernet 0/0/0
[R1-Ethernet0/0/0]ip address 192.168.1.146 28
[R1-Ethernet0/0/0]q
[R1]interface Ethernet 0/0/1
[R1-Ethernet0/0/1]ip address 192.168.1.193 28
[R1-Ethernet0/0/1]q
[R1]interface g 0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.1.209 28
[R1-GigabitEthernet0/0/0]display this //显示该接口ip地址
#
interface GigabitEthernet0/0/0
ip address 192.168.1.209 255.255.255.240
#
return
[R1-GigabitEthernet0/0/0]q
[R1]interface g 0/0/1
[R1-GigabitEthernet0/0/1]ip address 192.168.1.98 28
[R1-GigabitEthernet0/0/1]q
[R1]interface LoopBack 0
[R1-LoopBack0]ip address 192.168.1.161 28
[R1-LoopBack0]q
[R1]interface LoopBack 1
[R1-LoopBack1]ip address 192.168.1.177 28
[R1-LoopBack1]q
[R1]display ip interface brief //显示该路由的接口情况
*down: administratively down
!down: FIB overload down
^down: standby
(l): loopback
(s): spoofing
(d): Dampening Suppressed
The number of interface that is UP in Physical is 7
The number of interface that is DOWN in Physical is 6
The number of interface that is UP in Protocol is 7
The number of interface that is DOWN in Protocol is 6
Interface IP Address/Mask Physical Protocol
Ethernet0/0/0 192.168.1.146/28 up up
Ethernet0/0/1 192.168.1.193/28 up up
GigabitEthernet0/0/0 192.168.1.209/28 up up
GigabitEthernet0/0/1 192.168.1.98/28 up up
GigabitEthernet0/0/2 unassigned down down
GigabitEthernet0/0/3 unassigned down down
LoopBack0 192.168.1.161/28 up up(s)
LoopBack1 192.168.1.177/28 up up(s)
NULL0 unassigned up up(s)
Serial0/0/0 unassigned down down
Serial0/0/1 unassigned down down
Serial0/0/2 unassigned down down
Serial0/0/3 unassigned down down
[R1]
<R1>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
配置AR4路由
<Huawei>system-view
[Huawei]sysname AR4
[AR4]interface GigabitEthernet 0/0/0
[AR4-GigabitEthernet0/0/0]ip address 192.168.1.194 28
[AR4-GigabitEthernet0/0/0]q
[AR4]interface g 0/0/1
[AR4-GigabitEthernet0/0/1]ip address 192.168.1.210 28
[AR4-GigabitEthernet0/0/1]q
[AR4]interface LoopBack 0
[AR4-LoopBack0]ip address 5.5.5.1 24
[AR4-LoopBack0]q
[AR4]q
<AR4>save
The current configuration will be written to the device.
Are you sure to continue? (y/n)[n]:y
- 配置静态路由
由于不能直接配通往5.5.5.0/24网段的静态路由,所以使用缺省路由。配置AR1的静态路由 <AR1>system-view [AR1]ip route-static 192.168.1.112 28 192.168.1.34 [AR1]ip route-static 192.168.1.128 28 192.168.1.34 [AR1]ip route-static 192.168.1.144 28 192.168.1.34 [AR1]ip route-static 192.168.1.160 28 192.168.1.34 [AR1]ip route-static 192.168.1.176 28 192.168.1.34 [AR1]ip route-static 192.168.1.192 28 192.168.1.34 [AR1]ip route-static 192.168.1.208 28 192.168.1.34 [AR1]ip route-static 192.168.1.64 28 192.168.1.50 [AR1]ip route-static 192.168.1.80 28 192.168.1.50 [AR1]ip route-static 192.168.1.96 28 192.168.1.50 [AR1]ip route-static 0.0.0.0 0 192.168.1.34 //配置静态路由 [AR1]display ip routing-table //显示路由表 Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 27 Routes : 27 Destination/Mask Proto Pre Cost Flags NextHop Interface 0.0.0.0/0 Static 60 0 RD 192.168.1.34 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 127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 192.168.1.0/28 Direct 0 0 D 192.168.1.1 LoopBack0 192.168.1.1/32 Direct 0 0 D 127.0.0.1 LoopBack0 192.168.1.15/32 Direct 0 0 D 127.0.0.1 LoopBack0 192.168.1.16/28 Direct 0 0 D 192.168.1.17 LoopBack1 192.168.1.17/32 Direct 0 0 D 127.0.0.1 LoopBack1 192.168.1.31/32 Direct 0 0 D 127.0.0.1 LoopBack1 192.168.1.32/28 Direct 0 0 D 192.168.1.33 GigabitEthernet 0/0/0 192.168.1.33/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/0 192.168.1.47/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/0 192.168.1.48/28 Direct 0 0 D 192.168.1.49 GigabitEthernet 0/0/1 192.168.1.49/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1 192.168.1.63/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1 192.168.1.64/28 Static 60 0 RD 192.168.1.50 GigabitEthernet 0/0/1 192.168.1.80/28 Static 60 0 RD 192.168.1.50 GigabitEthernet 0/0/1 192.168.1.96/28 Static 60 0 RD 192.168.1.50 GigabitEthernet 0/0/1 192.168.1.112/28 Static 60 0 RD 192.168.1.34 GigabitEthernet 0/0/0 192.168.1.128/28 Static 60 0 RD 192.168.1.34 GigabitEthernet 0/0/0 192.168.1.144/28 Static 60 0 RD 192.168.1.34 GigabitEthernet 0/0/0 192.168.1.160/28 Static 60 0 RD 192.168.1.34 GigabitEthernet 0/0/0 192.168.1.176/28 Static 60 0 RD 192.168.1.34 GigabitEthernet 0/0/0 192.168.1.192/28 Static 60 0 RD 192.168.1.34 GigabitEthernet 0/0/0 192.168.1.208/28 Static 60 0 RD 192.168.1.34 GigabitEthernet 0/0/0 255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 [AR1]q <AR1>save The current configuration will be written to the device. Are you sure to continue? (y/n)[n]:y
配置AR2静态路由 <AR2>system-view [AR2]ip route-static 192.168.1.0 28 192.168.1.33 [AR2]ip route-static 192.168.1.16 28 192.168.1.33 [AR2]ip route-static 192.168.1.48 28 192.168.1.33 [AR2]ip route-static 192.168.1.64 28 192.168.1.33 [AR2]ip route-static 192.168.1.80 28 192.168.1.33 [AR2]ip route-static 192.168.1.160 28 192.168.1.146 [AR2]ip route-static 192.168.1.176 28 192.168.1.146 [AR2]ip route-static 192.168.1.192 28 192.168.1.146 [AR2]ip route-static 192.168.1.208 28 192.168.1.146 [AR2]ip route-static 192.168.1.96 28 192.168.1.146 [AR2]ip route-static 0.0.0.0 0 192.168.1.146 [AR2]display ip routing-table Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 27 Routes : 27 Destination/Mask Proto Pre Cost Flags NextHop Interface 0.0.0.0/0 Static 60 0 RD 192.168.1.146 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 127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 192.168.1.0/28 Static 60 0 RD 192.168.1.33 GigabitEthernet 0/0/1 192.168.1.16/28 Static 60 0 RD 192.168.1.33 GigabitEthernet 0/0/1 192.168.1.32/28 Direct 0 0 D 192.168.1.34 GigabitEthernet 0/0/1 192.168.1.34/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1 192.168.1.47/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1 192.168.1.48/28 Static 60 0 RD 192.168.1.33 GigabitEthernet 0/0/1 192.168.1.64/28 Static 60 0 RD 192.168.1.33 GigabitEthernet 0/0/1 192.168.1.80/28 Static 60 0 RD 192.168.1.33 GigabitEthernet 0/0/1 192.168.1.96/28 Static 60 0 RD 192.168.1.146 GigabitEthernet 0/0/0 192.168.1.112/28 Direct 0 0 D 192.168.1.113 LoopBack0 192.168.1.113/32 Direct 0 0 D 127.0.0.1 LoopBack0 192.168.1.127/32 Direct 0 0 D 127.0.0.1 LoopBack0 192.168.1.128/28 Direct 0 0 D 192.168.1.129 LoopBack1 192.168.1.129/32 Direct 0 0 D 127.0.0.1 LoopBack1 192.168.1.143/32 Direct 0 0 D 127.0.0.1 LoopBack1 192.168.1.144/28 Direct 0 0 D 192.168.1.145 GigabitEthernet 0/0/0 192.168.1.145/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/0 192.168.1.159/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/0 192.168.1.160/28 Static 60 0 RD 192.168.1.146 GigabitEthernet 0/0/0 192.168.1.176/28 Static 60 0 RD 192.168.1.146 GigabitEthernet 0/0/0 192.168.1.192/28 Static 60 0 RD 192.168.1.146 GigabitEthernet 0/0/0 192.168.1.208/28 Static 60 0 RD 192.168.1.146 GigabitEthernet 0/0/0 255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 [AR2]q <AR2>save The current configuration will be written to the device. Are you sure to continue? (y/n)[n]:y
配置AR3静态路由 <AR3>system-view [AR3]ip route-static 192.168.1.0 28 192.168.1.49 [AR3]ip route-static 192.168.1.16 28 192.168.1.49 [AR3]ip route-static 192.168.1.32 28 192.168.1.49 [AR3]ip route-static 192.168.1.112 28 192.168.1.49 [AR3]ip route-static 192.168.1.128 28 192.168.1.49 [AR3]ip route-static 192.168.1.144 28 192.168.1.98 [AR3]ip route-static 192.168.1.160 28 192.168.1.98 [AR3]ip route-static 192.168.1.176 28 192.168.1.98 [AR3]ip route-static 192.168.1.192 28 192.168.1.98 [AR3]ip route-static 192.168.1.208 28 192.168.1.98 [AR3]ip route-static 0.0.0.0 0 192.168.1.98 [AR3]display ip routing-table Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 27 Routes : 27 Destination/Mask Proto Pre Cost Flags NextHop Interface 0.0.0.0/0 Static 60 0 RD 192.168.1.98 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 127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 192.168.1.0/28 Static 60 0 RD 192.168.1.49 GigabitEthernet 0/0/1 192.168.1.16/28 Static 60 0 RD 192.168.1.49 GigabitEthernet 0/0/1 192.168.1.32/28 Static 60 0 RD 192.168.1.49 GigabitEthernet 0/0/1 192.168.1.48/28 Direct 0 0 D 192.168.1.50 GigabitEthernet 0/0/1 192.168.1.50/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1 192.168.1.63/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/1 192.168.1.64/28 Direct 0 0 D 192.168.1.65 LoopBack0 192.168.1.65/32 Direct 0 0 D 127.0.0.1 LoopBack0 192.168.1.79/32 Direct 0 0 D 127.0.0.1 LoopBack0 192.168.1.80/28 Direct 0 0 D 192.168.1.81 LoopBack1 192.168.1.81/32 Direct 0 0 D 127.0.0.1 LoopBack1 192.168.1.95/32 Direct 0 0 D 127.0.0.1 LoopBack1 192.168.1.96/28 Direct 0 0 D 192.168.1.97 GigabitEthernet 0/0/0 192.168.1.97/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/0 192.168.1.111/32 Direct 0 0 D 127.0.0.1 GigabitEthernet 0/0/0 192.168.1.112/28 Static 60 0 RD 192.168.1.49 GigabitEthernet 0/0/1 192.168.1.128/28 Static 60 0 RD 192.168.1.49 GigabitEthernet 0/0/1 192.168.1.144/28 Static 60 0 RD 192.168.1.98 GigabitEthernet 0/0/0 192.168.1.160/28 Static 60 0 RD 192.168.1.98 GigabitEthernet 0/0/0 192.168.1.176/28 Static 60 0 RD 192.168.1.98 GigabitEthernet 0/0/0 192.168.1.192/28 Static 60 0 RD 192.168.1.98 GigabitEthernet 0/0/0 192.168.1.208/28 Static 60 0 RD 192.168.1.98 GigabitEthernet 0/0/0 255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 [AR3]q <AR3>save The current configuration will be written to the device. Are you sure to continue? (y/n)[n]:y
配置R1静态路由 <R1>system-view [R1]ip route-static 192.168.1.128 28 192.168.1.145 [R1]ip route-static 192.168.1.112 28 192.168.1.145 [R1]ip route-static 192.168.1.32 28 192.168.1.145 [R1]ip route-static 192.168.1.0 28 192.168.1.145 [R1]ip route-static 192.168.1.16 28 192.168.1.145 [R1]ip route-static 192.168.1.48 28 192.168.1.97 [R1]ip route-static 192.168.1.64 28 192.168.1.97 [R1]ip route-static 192.168.1.80 28 192.168.1.97 [R1]ip route-static 0.0.0.0 0 192.168.1.194 [R1]ip route-static 0.0.0.0 0 192.168.1.210 preference 70 // 浮动静态路由 [R1]display ip routing-table protocol static //查询由静态路由生成的路由表 Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Public routing table : Static Destinations : 9 Routes : 10 Configured Routes : 10 Static routing table status : <Active> Destinations : 9 Routes : 9 Destination/Mask Proto Pre Cost Flags NextHop Interface 0.0.0.0/0 Static 60 0 RD 192.168.1.194 Ethernet0/0/1 192.168.1.0/28 Static 60 0 RD 192.168.1.145 Ethernet0/0/0 192.168.1.16/28 Static 60 0 RD 192.168.1.145 Ethernet0/0/0 192.168.1.32/28 Static 60 0 RD 192.168.1.145 Ethernet0/0/0 192.168.1.48/28 Static 60 0 RD 192.168.1.97 GigabitEthernet 0/0/1 192.168.1.64/28 Static 60 0 RD 192.168.1.97 GigabitEthernet 0/0/1 192.168.1.80/28 Static 60 0 RD 192.168.1.97 GigabitEthernet 0/0/1 192.168.1.112/28 Static 60 0 RD 192.168.1.145 Ethernet0/0/0 192.168.1.128/28 Static 60 0 RD 192.168.1.145 Ethernet0/0/0 Static routing table status : <Inactive> Destinations : 1 Routes : 1 Destination/Mask Proto Pre Cost Flags NextHop Interface 0.0.0.0/0 Static 70 0 R 192.168.1.210 GigabitEthernet 0/0/0 [R1]q <R1>save The current configuration will be written to the device. Are you sure to continue?[Y/N]y
配置R4静态路由 <AR4>system-view [AR4]ip route-static 192.168.1.0 24 192.168.1.193 //子网汇总 [AR4]ip route-static 192.168.1.0 24 192.168.1.209 preference 70 [AR4]display ip routing-table protocol static Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Public routing table : Static Destinations : 1 Routes : 2 Configured Routes : 2 Static routing table status : <Active> Destinations : 1 Routes : 1 Destination/Mask Proto Pre Cost Flags NextHop Interface 192.168.1.0/24 Static 60 0 RD 192.168.1.193 GigabitEthernet 0/0/0 Static routing table status : <Inactive> Destinations : 1 Routes : 1 Destination/Mask Proto Pre Cost Flags NextHop Interface 192.168.1.0/24 Static 70 0 R 192.168.1.209 GigabitEthernet 0/0/1 [AR4]q <AR4>save The current configuration will be written to the device. Are you sure to continue? (y/n)[n]:y
- 解决路由黑洞加缺省路由形成的路由环路问题
在R1上增加一个空接口路由。
作用原理:路由器的匹配原则(最长匹配原则/精确匹配原则)
根据题目:- 192.168.1.254/28在本题是没有配置的网段。它这个目标ip从AR4中发出时,经过R1路由器,然后根据R1的路由表进行匹配。最接近的网段是192.168.1.0/24,从而丢弃。而不是匹配到0.0.0.0/0网段继续转发给AR4路由,从而避免路由环路。
- 192.168.1.0/28在本题中是配置成功的网段。它这个目标ip从AR4中发出时,经过R1路由器,然后根据R1的路由表进行匹配。最接近的网段是192.168.1.0/28,没有被丢弃,继续转发给AR2路由,再转发给AR1路由,继而转发成功。
第一种情况:成功丢弃配置R1路由器 <R1>system-view [R1]ip route-static 192.168.1.0 24 NULL 0 [R1]display ip routing-table protocol static Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Public routing table : Static Destinations : 10 Routes : 11 Configured Routes : 11 Static routing table status : <Active> Destinations : 10 Routes : 10 Destination/Mask Proto Pre Cost Flags NextHop Interface 0.0.0.0/0 Static 60 0 RD 192.168.1.194 Ethernet0/0/1 192.168.1.0/24 Static 60 0 D 0.0.0.0 NULL0 192.168.1.0/28 Static 60 0 RD 192.168.1.145 Ethernet0/0/0 192.168.1.16/28 Static 60 0 RD 192.168.1.145 Ethernet0/0/0 192.168.1.32/28 Static 60 0 RD 192.168.1.145 Ethernet0/0/0 192.168.1.48/28 Static 60 0 RD 192.168.1.97 GigabitEthernet 0/0/1 192.168.1.64/28 Static 60 0 RD 192.168.1.97 GigabitEthernet 0/0/1 192.168.1.80/28 Static 60 0 RD 192.168.1.97 GigabitEthernet 0/0/1 192.168.1.112/28 Static 60 0 RD 192.168.1.145 Ethernet0/0/0 192.168.1.128/28 Static 60 0 RD 192.168.1.145 Ethernet0/0/0 Static routing table status : <Inactive> Destinations : 1 Routes : 1 Destination/Mask Proto Pre Cost Flags NextHop Interface 0.0.0.0/0 Static 70 0 R 192.168.1.210 GigabitEthernet 0/0/0 [R1]q The current configuration will be written to the device. Are you sure to continue?[Y/N]y
第二种情况:成功ping通