华为路由器配置静态路由,如果只包含出接口,静态路由可以存在于路由表,但不能转发数据,因为他的下一跳显示的是他的出接口,这条静态路由的出接口和下一跳地址为同一个地址。
R1预配
<Huawei>sy
Enter system view, return user view with Ctrl+Z.
[Huawei]sy AR1
[AR1]int lo 0
[AR1-LoopBack0]ip add 1.1.1.1 32
[AR1-LoopBack0]int g0/0/0
[AR1-GigabitEthernet0/0/0]ip add 12.1.1.1 24
[AR1-GigabitEthernet0/0/0]q
[AR1]dis ip int br
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 3
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 2
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 3
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 2
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 12.1.1.1/24 up up
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 unassigned down down
LoopBack0 1.1.1.1/32 up up(s)
NULL0 unassigned up up(s)
GigabitEthernet0/0/0 12.1.1.1/24 up up
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 unassigned down down
LoopBack0 1.1.1.1/32 up up(s)
NULL0 unassigned up up(s)
R2预配
[Huawei]sy AR2
[AR2]int lo 0
[AR2-LoopBack0]ip add 2.2.2.2 32
[AR2-LoopBack0]int g0/0/2
[AR2-GigabitEthernet0/0/2]ip add 12.1.1.2 24
[AR2-GigabitEthernet0/0/2]dis ip int br
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 3
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 2
[AR2]int lo 0
[AR2-LoopBack0]ip add 2.2.2.2 32
[AR2-LoopBack0]int g0/0/2
[AR2-GigabitEthernet0/0/2]ip add 12.1.1.2 24
[AR2-GigabitEthernet0/0/2]dis ip int br
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 3
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 2
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 unassigned down down
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 12.1.1.2/24 up up
LoopBack0 2.2.2.2/32 up up(s)
NULL0 unassigned up up(s)
GigabitEthernet0/0/0 unassigned down down
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 12.1.1.2/24 up up
LoopBack0 2.2.2.2/32 up up(s)
NULL0 unassigned up up(s)
R1配置去往2网络的静态路由,只包含出接口
[AR1]ip route-static 2.2.2.0 255.255.255.0 g0/0/0
查看R1路由表
<AR1>dis ip routing-table protocol static
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : Static
Destinations : 1 Routes : 1 Configured Routes : 1
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : Static
Destinations : 1 Routes : 1 Configured Routes : 1
Static routing table status : <Active>
Destinations : 1 Routes : 1
Destinations : 1 Routes : 1
Destination/Mask Proto Pre Cost Flags NextHop Interface
2.2.2.0/24 Static 60 0 D 12.1.1.1 GigabitEthernet
0/0/0
0/0/0
Static routing table status : <Inactive>
Destinations : 0 Routes : 0
Destinations : 0 Routes : 0
<AR1>
R2配置去往1网络的静态路由,只包含出接口
[AR2]ip route-static 1.1.1.0 255.255.255.0 g0/0/2
查看R2路由表
[AR2]dis ip routing-table protocol static
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : Static
Destinations : 1 Routes : 1 Configured Routes : 1
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : Static
Destinations : 1 Routes : 1 Configured Routes : 1
Static routing table status : <Active>
Destinations : 1 Routes : 1
Destinations : 1 Routes : 1
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.0/24 Static 60 0 D 12.1.1.2 GigabitEthernet
0/0/2
0/0/2
Static routing table status : <Inactive>
Destinations : 0 Routes : 0
Destinations : 0 Routes : 0
[AR2]
R1 ping R2
[AR1]ping 2.2.2.2
PING 2.2.2.2: 56 data bytes, press CTRL_C to break
Request time out
Request time out
Request time out
Request time out
Request time out
PING 2.2.2.2: 56 data bytes, press CTRL_C to break
Request time out
Request time out
Request time out
Request time out
Request time out
--- 2.2.2.2 ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
[AR1]
[AR1]ping -a 1.1.1.1 2.2.2.2
PING 2.2.2.2: 56 data bytes, press CTRL_C to break
Request time out
Request time out
Request time out
Request time out
Request time out
PING 2.2.2.2: 56 data bytes, press CTRL_C to break
Request time out
Request time out
Request time out
Request time out
Request time out
--- 2.2.2.2 ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
[AR1]
总结:华为路由器配置静态路由,不能只有出接口,一定要连下一跳地址