华为路由器配置静态路由
程序员文章站
2024-03-20 22:06:40
...
一、配置IP地址
R1路由器配置
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 10.0.13.1 24
[R1-GigabitEthernet0/0/0]quit
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]ip address 10.0.12.1 24
[R1-GigabitEthernet0/0/1]quit
[R1]interface LoopBack 0
[R1-LoopBack0]ip address 10.0.1.1 24
R2路由器配置
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R2
[R2]interface GigabitEthernet 0/0/1
[R2-GigabitEthernet0/0/1]ip address 10.0.12.2 24
[R2-GigabitEthernet0/0/1]quit
[R2]interface GigabitEthernet 0/0/2
[R2-GigabitEthernet0/0/2]ip address 10.0.23.1 24
[R2-GigabitEthernet0/0/2]quit
[R2]interface LoopBack 0
[R2-LoopBack0]ip address 10.0.2.2 24
R3路由器配置
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R3
[R3]interface GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]ip address 10.0.13.2 24
[R3-GigabitEthernet0/0/0]quit
[R3]interface GigabitEthernet 0/0/2
[R3-GigabitEthernet0/0/2]ip address 10.0.23.2 24
[R3-GigabitEthernet0/0/2]quit
[R3]interface LoopBack 0
[R3-LoopBack0]ip address 10.0.3.3 24
检测设备之间的连通性
R1 ping10.0.13.2
PING 10.0.13.2: 56 data bytes, press CTRL_C to break
Reply from 10.0.13.2: bytes=56 Sequence=1 ttl=255 time=50 ms
Reply from 10.0.13.2: bytes=56 Sequence=2 ttl=255 time=40 ms
Reply from 10.0.13.2: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 10.0.13.2: bytes=56 Sequence=4 ttl=255 time=30 ms
Reply from 10.0.13.2: bytes=56 Sequence=5 ttl=255 time=10 ms
--- 10.0.13.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 10/30/50 ms
ping 10.0.12.2
PING 10.0.12.2: 56 data bytes, press CTRL_C to break
Reply from 10.0.12.2: bytes=56 Sequence=1 ttl=255 time=40 ms
Reply from 10.0.12.2: bytes=56 Sequence=2 ttl=255 time=30 ms
Reply from 10.0.12.2: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 10.0.12.2: bytes=56 Sequence=4 ttl=255 time=20 ms
Reply from 10.0.12.2: bytes=56 Sequence=5 ttl=255 time=30 ms
--- 10.0.12.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/28/40 ms
依照此方法测试R2,R3各设备间的连通性。
然后测试R2到目的网络 10.0.13.0/24、10.0.3.0/24 的连通性
PING 10.0.13.3: 56 data bytes, press CTRL_C to break
Request time out
Request time out
Request time out
Request time out
Request time out
--- 10.0.13.3 ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
PING 10.0.3.3: 56 data bytes, press CTRL_C to break
Request time out
Request time out
Request time out
Request time out
Request time out
--- 10.0.3.3 ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
如果R2要与10.0.3.0/24网络通信,需要R2上有去往该网段的路由信息,并且R3上也需要有到R2相应接口所在IP网段的路由信息。
二、配置静态路由
2.1在R2上配置静态路由
配置目的地址为10.0.13.0/24和10.0.3.0/24的静态路由,路由的下一跳配置为R3的G0/0/0接口IP地址10.0.23.2。
[R2]ip route-static 10.0.13.0 24 10.0.23.2
[R2]ip route-static 10.0.3.0 24 10.0.23.2
验证静态路由
tracert 10.0.13.2
traceroute to 10.0.13.2(10.0.13.2), max hops: 30 ,packet length: 40,press CTRL
_C to break
1 10.0.23.2 30 ms 20 ms 30 ms
tracert 10.0.3.3
traceroute to 10.0.3.3(10.0.3.3), max hops: 30 ,packet length: 40,press CTRL_C
to break
1 10.0.23.2 40 ms 20 ms 20 ms
静态路由配置完成。
上一篇: 上传代码到github