要求:用静态路由中的下一跳方法和环回接口实现三台路由器的全网可达
1.先配置三台路由总共四个物理接口的ip
<Huawei>sys
[Huawei]sys r1
[r1]user-interface console 0
[r1-ui-console0]idle-timeout 0 0
[r1]interface GigabitEthernet 0/0/0
[r1-GigabitEthernet0/0/0]ip address 12.1.1.1 24
Apr 7 2023 23:22:34-08:00 r1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
<Huawei>sys
[Huawei]sys r2
[r2]user-interface console 0
[r2-ui-console0]idle-timeout 0 0
[r2]interface GigabitEthernet 0/0/1
[r2-GigabitEthernet0/0/1]ip ad 12.1.1.2 24
Apr 7 2023 23:23:48-08:00 r2 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[r2]interface GigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]ip ad 24.1.1.1 24
Apr 7 2023 23:24:33-08:00 r2 %%01IFNET/4/LINK_STATE(l)[3]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
<Huawei>sys
[Huawei]sys r3
[r3]user-interface console 0
[r3-ui-console0]idle-timeout 0 0
[r3]interface GigabitEthernet 0/0/1
[r3-GigabitEthernet0/0/1]ip ad 24.1.1.2 24
Apr 7 2023 23:25:09-08:00 r3 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
2.利用下一跳做好四个接口的路由
[r1]ip route-static 24.1.1.0 24 12.1.1.2
[r3]ip route-static 12.1.1.0 24 24.1.1.1
r2在中间直连r1和r3,故不用配置。路由与通信没有直接关系,在只配置一台下一跳路由时,r1有了到r3的路由,但是r3不知道r1的网段,数据从r1到r3后,r3不能将数据路由到r1,这一点需要注意。
3.创建环回接口(虚拟接口),并实现三台路由器之间的环回路由
[r1]interface LoopBack 0
[r1-LoopBack0]ip ad 1.1.1.1 24
[r2]interface LoopBack 0
[r2-LoopBack0]ip ad 2.2.2.2 24
[r3]interface LoopBack 0
[r3-LoopBack0]ip ad 3.3.3.3 24
配置三个路由器的环回接口,然后配置三个接口的路由。虽然两两之间进行了物理直连,但是虚拟接口之间并没有路由通信,所以要让互相路由。
r1配置:
[r1]ip route-static 2.2.2.0 24 12.1.1.2
[r1]ip route-static 3.3.3.0 24 12.1.1.2
r2配置:
[r2]ip route-static 1.1.1.0 24 12.1.1.1
[r2]ip route-static 3.3.3.0 24 24.1.1.2
r3配置:
[r3]ip route-static 1.1.1.0 24 24.1.1.1
[r3]ip route-static 2.2.2.0 24 24.1.1.1
4.查看路由表:
在最后养成查看路由表的习惯,其实要在每一步都要检查一下自己的路由表为及时改正错误。我这里已经直接把路由配完了。所以最后查看路由表。
r1路由表:
[r1]dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 13 Routes : 13
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.0/24 Direct 0 0 D 1.1.1.1 LoopBack0
1.1.1.1/32 Direct 0 0 D 127.0.0.1 LoopBack0
1.1.1.255/32 Direct 0 0 D 127.0.0.1 LoopBack0
2.2.2.0/24 Static 60 0 RD 12.1.1.2 GigabitEthernet
0/0/0
3.3.3.0/24 Static 60 0 RD 12.1.1.2 GigabitEthernet
0/0/0
12.1.1.0/24 Direct 0 0 D 12.1.1.1 GigabitEthernet
0/0/0
12.1.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
12.1.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
24.1.1.0/24 Static 60 0 RD 12.1.1.2 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
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
r2路由表:
[r2]dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 15 Routes : 15
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.0/24 Static 60 0 RD 12.1.1.1 GigabitEthernet
0/0/1
2.2.2.0/24 Direct 0 0 D 2.2.2.2 LoopBack0
2.2.2.2/32 Direct 0 0 D 127.0.0.1 LoopBack0
2.2.2.255/32 Direct 0 0 D 127.0.0.1 LoopBack0
3.3.3.0/24 Static 60 0 RD 24.1.1.2 GigabitEthernet
0/0/0
12.1.1.0/24 Direct 0 0 D 12.1.1.2 GigabitEthernet
0/0/1
12.1.1.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
12.1.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
24.1.1.0/24 Direct 0 0 D 24.1.1.1 GigabitEthernet
0/0/0
24.1.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
24.1.1.255/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
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
r3路由表:
[r3]dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 13 Routes : 13
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.0/24 Static 60 0 RD 24.1.1.1 GigabitEthernet
0/0/1
2.2.2.0/24 Static 60 0 RD 24.1.1.1 GigabitEthernet
0/0/1
3.3.3.0/24 Direct 0 0 D 3.3.3.3 LoopBack0
3.3.3.3/32 Direct 0 0 D 127.0.0.1 LoopBack0
3.3.3.255/32 Direct 0 0 D 127.0.0.1 LoopBack0
12.1.1.0/24 Static 60 0 RD 24.1.1.1 GigabitEthernet
0/0/1
24.1.1.0/24 Direct 0 0 D 24.1.1.2 GigabitEthernet
0/0/1
24.1.1.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
24.1.1.255/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
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
5.结果:文章来源:https://www.toymoban.com/news/detail-508567.html
r1:
[r1]ping 2.2.2.2
PING 2.2.2.2: 56 data bytes, press CTRL_C to break
Reply from 2.2.2.2: bytes=56 Sequence=1 ttl=255 time=40 ms
Reply from 2.2.2.2: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 2.2.2.2: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 2.2.2.2: bytes=56 Sequence=4 ttl=255 time=20 ms
Reply from 2.2.2.2: bytes=56 Sequence=5 ttl=255 time=40 ms
[r1]ping 3.3.3.3
PING 3.3.3.3: 56 data bytes, press CTRL_C to break
Reply from 3.3.3.3: bytes=56 Sequence=1 ttl=254 time=20 ms
Reply from 3.3.3.3: bytes=56 Sequence=2 ttl=254 time=20 ms
Reply from 3.3.3.3: bytes=56 Sequence=3 ttl=254 time=40 ms
Reply from 3.3.3.3: bytes=56 Sequence=4 ttl=254 time=30 ms
Reply from 3.3.3.3: bytes=56 Sequence=5 ttl=254 time=40 ms
[r1]ping 24.1.1.2
PING 24.1.1.2: 56 data bytes, press CTRL_C to break
Reply from 24.1.1.2: bytes=56 Sequence=1 ttl=254 time=30 ms
Reply from 24.1.1.2: bytes=56 Sequence=2 ttl=254 time=20 ms
Reply from 24.1.1.2: bytes=56 Sequence=3 ttl=254 time=30 ms
Reply from 24.1.1.2: bytes=56 Sequence=4 ttl=254 time=30 ms
Reply from 24.1.1.2: bytes=56 Sequence=5 ttl=254 time=30 ms
r2:
[r2]ping 1.1.1.1
PING 1.1.1.1: 56 data bytes, press CTRL_C to break
Reply from 1.1.1.1: bytes=56 Sequence=1 ttl=255 time=20 ms
Reply from 1.1.1.1: bytes=56 Sequence=2 ttl=255 time=30 ms
Reply from 1.1.1.1: bytes=56 Sequence=3 ttl=255 time=30 ms
Reply from 1.1.1.1: bytes=56 Sequence=4 ttl=255 time=40 ms
Reply from 1.1.1.1: bytes=56 Sequence=5 ttl=255 time=20 ms
[r2]ping 3.3.3.3
PING 3.3.3.3: 56 data bytes, press CTRL_C to break
Reply from 3.3.3.3: bytes=56 Sequence=1 ttl=255 time=20 ms
Reply from 3.3.3.3: bytes=56 Sequence=2 ttl=255 time=10 ms
Reply from 3.3.3.3: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 3.3.3.3: bytes=56 Sequence=4 ttl=255 time=20 ms
Reply from 3.3.3.3: bytes=56 Sequence=5 ttl=255 time=40 ms
r3:
[r3]ping 1.1.1.1
PING 1.1.1.1: 56 data bytes, press CTRL_C to break
Reply from 1.1.1.1: bytes=56 Sequence=1 ttl=254 time=30 ms
Reply from 1.1.1.1: bytes=56 Sequence=2 ttl=254 time=40 ms
Reply from 1.1.1.1: bytes=56 Sequence=3 ttl=254 time=40 ms
Reply from 1.1.1.1: bytes=56 Sequence=4 ttl=254 time=40 ms
Reply from 1.1.1.1: bytes=56 Sequence=5 ttl=254 time=30 ms
[r3]ping 2.2.2.2
PING 2.2.2.2: 56 data bytes, press CTRL_C to break
Reply from 2.2.2.2: bytes=56 Sequence=1 ttl=255 time=20 ms
Reply from 2.2.2.2: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 2.2.2.2: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 2.2.2.2: bytes=56 Sequence=4 ttl=255 time=20 ms
Reply from 2.2.2.2: bytes=56 Sequence=5 ttl=255 time=40 ms
[r3]ping 12.1.1.1
PING 12.1.1.1: 56 data bytes, press CTRL_C to break
Reply from 12.1.1.1: bytes=56 Sequence=1 ttl=254 time=20 ms
Reply from 12.1.1.1: bytes=56 Sequence=2 ttl=254 time=40 ms
Reply from 12.1.1.1: bytes=56 Sequence=3 ttl=254 time=30 ms
Reply from 12.1.1.1: bytes=56 Sequence=4 ttl=254 time=30 ms
Reply from 12.1.1.1: bytes=56 Sequence=5 ttl=254 time=40 ms
文章来源地址https://www.toymoban.com/news/detail-508567.html
到了这里,关于静态路由用下一跳方法配置的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!