先配一下三个路由的地址
第一个的IP
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname 1
[1]interface g0/0/0
[1-GigabitEthernet0/0/0]ip address 12.1.1.1 24
Nov 14 2022 19:13:45-08:00 1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP o
n the interface GigabitEthernet0/0/0 has entered the UP state.
[1-GigabitEthernet0/0/0]
第二个的IP
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname 2
[2]interface g0/0/0
[2-GigabitEthernet0/0/0]ip address 12.1.1.2 24
Nov 14 2022 19:15:06-08:00 2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP o
n the interface GigabitEthernet0/0/0 has entered the UP state.
[2-GigabitEthernet0/0/0]quit
[2]interface g0/0/1
[2-GigabitEthernet0/0/1]ip address 23.1.1.1 24
Nov 14 2022 19:16:19-08:00 2 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP o
n the interface GigabitEthernet0/0/1 has entered the UP state.
[2-GigabitEthernet0/0/1]
Please check whether system data has been changed, and save data in time
Configuration console time out, please press any key to log on
第三个的IP
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname 3
[3]interface g0/0/0
[3-GigabitEthernet0/0/0]ip address 23.1.1.2 24
Nov 14 2022 19:17:37-08:00 3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP o
n the interface GigabitEthernet0/0/0 has entered the UP state.
[3-GigabitEthernet0/0/0]
1和2,可以ping通
<1>system-view
Enter system view, return user view with Ctrl+Z.
[1]ping 12.1.1.2
PING 12.1.1.2: 56 data bytes, press CTRL_C to break
Reply from 12.1.1.2: bytes=56 Sequence=1 ttl=255 time=150 ms
Reply from 12.1.1.2: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 12.1.1.2: bytes=56 Sequence=3 ttl=255 time=40 ms
Reply from 12.1.1.2: bytes=56 Sequence=4 ttl=255 time=20 ms
Reply from 12.1.1.2: bytes=56 Sequence=5 ttl=255 time=10 ms
--- 12.1.1.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/48/150 ms
[1]
2和3,可以ping通
<2>system-view
Enter system view, return user view with Ctrl+Z.
[2]ping 23.1.1.2
PING 23.1.1.2: 56 data bytes, press CTRL_C to break
Reply from 23.1.1.2: bytes=56 Sequence=1 ttl=255 time=90 ms
Reply from 23.1.1.2: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 23.1.1.2: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 23.1.1.2: bytes=56 Sequence=4 ttl=255 time=20 ms
Reply from 23.1.1.2: bytes=56 Sequence=5 ttl=255 time=20 ms
--- 23.1.1.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/34/90 ms
[2]
查找1的路由表
[1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost Flags NextHop Interface
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
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
[1]
查找2的路由表
<2>system-view
Enter system view, return user view with Ctrl+Z.
[2]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 10 Routes : 10
Destination/Mask Proto Pre Cost Flags NextHop Interface
12.1.1.0/24 Direct 0 0 D 12.1.1.2 GigabitEthernet
0/0/0
12.1.1.2/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
23.1.1.0/24 Direct 0 0 D 23.1.1.1 GigabitEthernet
0/0/1
23.1.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
23.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
[2]
1的静态路由
<1>system-view
Enter system view, return user view with Ctrl+Z.
[1]ip route-static 23.1.1.0 24 12.1.1.2
再次查看路由
[1]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
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
23.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
[1]
3给1,2回包
<3>system-view
Enter system view, return user view with Ctrl+Z.
[3]ip route-static 12.1.1.0 24 23.1.1.1
[3]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
12.1.1.0/24 Static 60 0 RD 23.1.1.1 GigabitEthernet
0/0/0
23.1.1.0/24 Direct 0 0 D 23.1.1.2 GigabitEthernet
0/0/0
23.1.1.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
23.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
[3]
此时1再去ping,3,可以ping通
[1]ping 23.1.1.2
PING 23.1.1.2: 56 data bytes, press CTRL_C to break
Reply from 23.1.1.2: bytes=56 Sequence=1 ttl=254 time=50 ms
Reply from 23.1.1.2: bytes=56 Sequence=2 ttl=254 time=30 ms
Reply from 23.1.1.2: bytes=56 Sequence=3 ttl=254 time=40 ms
Reply from 23.1.1.2: bytes=56 Sequence=4 ttl=254 time=20 ms
Reply from 23.1.1.2: bytes=56 Sequence=5 ttl=254 time=30 ms
--- 23.1.1.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/34/50 ms
[1]