eNSP-静态路由表的配置
文章目录
- eNSP-静态路由表的配置
- 一、拓扑结构
- 二、关键语句
- 三、完整代码
- 四、测试验证
一、拓扑结构
二、关键语句
ip route-static x.x.x.x y z.z.z.z
语法:目标网段 掩码 下一跳
例如
PC1所在网段访问PC2所在网段
在AR1中输入
ip route-static 192.168.2.0 24 2.0.0.2
PC1所在网段访问PC3所在网段
在AR1中输入
ip route-static 192.168.3.0 24 2.0.0.2
三、完整代码
1.PC1,PC2,PC3 ip配置如图所示;
2.路由器配置:
AR1:
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]int g0/0/0
Jul 2 2023 10:11:16-08:00 Huawei %%01IFPDT/4/IF_STATE(l)[0]:Interface GigabitEt
hernet0/0/1 has turned into UP state.
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.168.1.1 24
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 2.0.0.1 8
Jul 2 2023 10:12:36-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[1]:The line protocol
IP on the interface GigabitEthernet0/0/1 has entered the UP state.
[Huawei-GigabitEthernet0/0/1]quit
[Huawei]ip route-static 192.168.2.0 24 2.0.0.2
[Huawei]ip route-static 192.168.3.0 24 2.0.0.2
AR2:
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.168.2.1 24
Jul 2 2023 10:15:43-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol
IP on the interface GigabitEthernet0/0/0 has entered the UP state.
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 2.0.0.2 8
Jul 2 2023 10:16:05-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[1]:The line protocol
IP on the interface GigabitEthernet0/0/1 has entered the UP state.
[Huawei-GigabitEthernet0/0/1]int g0/0/2
[Huawei-GigabitEthernet0/0/2]ip address 3.0.0.2 8
Jul 2 2023 10:16:19-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[2]:The line protocol
IP on the interface GigabitEthernet0/0/2 has entered the UP state.
[Huawei-GigabitEthernet0/0/2]quit
[Huawei]ip route-static 192.168.1.0 24 2.0.0.1
[Huawei]ip route-static 192.168.3.0 24 3.0.0.1
AR3:
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.168.3.1 24
Jul 2 2023 10:14:41-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol
IP on the interface GigabitEthernet0/0/0 has entered the UP state.
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 3.0.0.1 8
Jul 2 2023 10:15:04-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[1]:The line protocol
IP on the interface GigabitEthernet0/0/1 has entered the UP state.
[Huawei-GigabitEthernet0/0/1]quit
[Huawei]ip route-static 192.168.2.0 24 3.0.0.2
[Huawei]ip route-static 192.168.1.0 24 3.0.0.2
四、测试验证
PC3pingPC1,PC2可达,证明全网连通。
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fed9:70f9
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.3.2
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.3.1
Physical address..................: 54-89-98-D9-70-F9
DNS server........................:
PC>ping 192.168.1.2
Ping 192.168.1.2: 32 data bytes, Press Ctrl_C to break
From 192.168.1.2: bytes=32 seq=1 ttl=125 time=16 ms
From 192.168.1.2: bytes=32 seq=2 ttl=125 time=31 ms
From 192.168.1.2: bytes=32 seq=3 ttl=125 time=31 ms
From 192.168.1.2: bytes=32 seq=4 ttl=125 time=32 ms
From 192.168.1.2: bytes=32 seq=5 ttl=125 time=31 ms
--- 192.168.1.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 16/28/32 ms
PC>ping 192.168.2.2
Ping 192.168.2.2: 32 data bytes, Press Ctrl_C to break
From 192.168.2.2: bytes=32 seq=1 ttl=126 time=16 ms
From 192.168.2.2: bytes=32 seq=2 ttl=126 time=31 ms
From 192.168.2.2: bytes=32 seq=3 ttl=126 time=16 ms
From 192.168.2.2: bytes=32 seq=4 ttl=126 time=15 ms
From 192.168.2.2: bytes=32 seq=5 ttl=126 time=16 ms
--- 192.168.2.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 15/18/31 ms