码迷,mamicode.com
首页 > 其他好文 > 详细

路由器静态IP的配置及其备份静态路由缺省路由

时间:2019-10-11 01:32:45      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:ping命令   tran   add   out   缺省   user   tin   oss   http   

静态路由时管理员手动配置并维护的路由。静态路由配置简单,被广泛应用于网络中。静态路由还可以实现负载均衡和路由备份。学习掌握好静态路由的配置是很重要的。

如下图,技术图片

 技术图片

首先进入路由器的命令视图,(sys)

 配置各个接口的ip地址

[Huawei]interface LoopBack 0
[Huawei-LoopBack0]ip address 10.0.2.2 24
[Huawei-LoopBack0]q
[Huawei]interface GigabitEthernet 0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 10.0.12.2 24
Oct 10 2019 21:55:49-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]q
[Huawei]interface GigabitEthernet 0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 10.0.23.2 24

配置静态路由,指向S3与S2配置格式为:ip route-static 路由器地址  掩码  接口地址

[Huawei]ip route-static 10.0.3.3 24 10.0.23.3
Info: The destination address and mask of the configured static route mismatched
, and the static route 10.0.3.0/24 was generated.
[Huawei]ip route-static 10.0.1.1 24 10.0.12.1
Info: The destination address and mask of the configured static route mismatched
, and the static route 10.0.1.0/24 was generated.

与上步格式相同,改变参数即可,此段代码配置的为S3的端口ip与静态路由

[Huawei-LoopBack0]ip address 10.0.3.3 24
[Huawei-LoopBack0]q
[Huawei]interface g
[Huawei]interface GigabitEthernet 0/0/0
[Huawei-GigabitEthernet0/0/0]ip a
[Huawei-GigabitEthernet0/0/0]ip accounting
[Huawei-GigabitEthernet0/0/0]ip address 10.0.23.3 24
Oct 10 2019 22:13:37-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]q
[Huawei]interface g
[Huawei]interface GigabitEthernet 0/0/1
[Huawei-GigabitEthernet0/0/1]ip a
[Huawei-GigabitEthernet0/0/1]ip accounting
[Huawei-GigabitEthernet0/0/1]ip address 10.0.13.3 24
Oct 10 2019 22:14:26-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]q
[Huawei]ip route
[Huawei]ip route
[Huawei]ip route-static 10.0.2.2 24 10.0.23.2
Info: The destination address and mask of the configured static route mismatched
, and the static route 10.0.2.0/24 was generated.
[Huawei]ip route
[Huawei]ip route
[Huawei]ip route-static 10.0.1.1 24 10.0.13.1
Info: The destination address and mask of the configured static route mismatched
, and the static route 10.0.1.0/24 was generated.

与上步格式相同,改变参数即可,此段代码配置的为S2的端口ip与静态路由

<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]interface loop
[Huawei]interface LoopBack 0
[Huawei-LoopBack0]ip a
[Huawei-LoopBack0]ip address 10.0.1.1 24
[Huawei-LoopBack0]q
[Huawei]interface g
[Huawei]interface GigabitEthernet 0/0/0
[Huawei-GigabitEthernet0/0/0]ip a
[Huawei-GigabitEthernet0/0/0]ip accounting
[Huawei-GigabitEthernet0/0/0]ip address 10.0.12.1 24
Oct 10 2019 22:18: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]q
[Huawei]interface g
[Huawei]interface GigabitEthernet 0/0/1
[Huawei-GigabitEthernet0/0/1]ip a
[Huawei-GigabitEthernet0/0/1]ip accounting
[Huawei-GigabitEthernet0/0/1]ip address 10.0.13.1 24
Oct 10 2019 22:19:32-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]q
[Huawei]ip route
[Huawei]ip route
[Huawei]ip route-static 10.0.2.2 24 10.0.12.2
Info: The destination address and mask of the configured static route mismatched
, and the static route 10.0.2.0/24 was generated.
[Huawei]ip route
[Huawei]ip route
[Huawei]ip route-static 10.0.3.3 24 10.0.13.3
Info: The destination address and mask of the configured static route mismatched
, and the static route 10.0.3.0/24 was generated.

 

测试是否ping通,经过测试发现都能实现互通,静态路由配置完毕

[Huawei]ping 10.0.1.1
PING 10.0.1.1: 56 data bytes, press CTRL_C to break
Reply from 10.0.1.1: bytes=56 Sequence=1 ttl=255 time=20 ms
Reply from 10.0.1.1: bytes=56 Sequence=2 ttl=255 time=30 ms
Reply from 10.0.1.1: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 10.0.1.1: bytes=56 Sequence=4 ttl=255 time=30 ms
Reply from 10.0.1.1: bytes=56 Sequence=5 ttl=255 time=30 ms

--- 10.0.1.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/26/30 ms

[Huawei]ping 10.0.3.3
PING 10.0.3.3: 56 data bytes, press CTRL_C to break
Reply from 10.0.3.3: bytes=56 Sequence=1 ttl=255 time=30 ms
Reply from 10.0.3.3: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 10.0.3.3: bytes=56 Sequence=3 ttl=255 time=20 ms
Reply from 10.0.3.3: bytes=56 Sequence=4 ttl=255 time=30 ms
Reply from 10.0.3.3: bytes=56 Sequence=5 ttl=255 time=30 ms

--- 10.0.3.3 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/26/30 ms

模拟网络发生故障,关闭S3的GE0/0/0端口并配置备份静态路由

技术图片

S3指向S1的备份静态路由

[Huawei]interface g
[Huawei]interface GigabitEthernet 0/0/0
[Huawei-GigabitEthernet0/0/0]shutdown   ####关闭0/0/0端口
Oct 10 2019 22:30:26-08:00 Huawei %%01IFPDT/4/IF_STATE(l)[0]:Interface GigabitEt
hernet0/0/0 has turned into DOWN state.
[Huawei-GigabitEthernet0/0/0]
[Huawei-GigabitEthernet0/0/0]
Oct 10 2019 22:30:26-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[1]:The line protocol
IP on the interface GigabitEthernet0/0/0 has entered the DOWN state.
[Huawei-GigabitEthernet0/0/0]q
[Huawei]ip rou
[Huawei]ip route
[Huawei]ip route-static 10.0.2.2 24 10.0.13.1
Info: The destination address and mask of the configured static route mismatched
, and the static route 10.0.2.0/24 was generated.
[Huawei]ip rou
[Huawei]ip route
[Huawei]ip route-static 10.0.12.2 24 10.0.13.1
Info: The destination address and mask of the configured static route mismatched
, and the static route 10.0.12.0/24 was generated.

实现互通,ping命令测试

[Huawei]ping 10.0.2.2
PING 10.0.2.2: 56 data bytes, press CTRL_C to break
Reply from 10.0.2.2: bytes=56 Sequence=1 ttl=254 time=30 ms
Reply from 10.0.2.2: bytes=56 Sequence=2 ttl=254 time=30 ms
Reply from 10.0.2.2: bytes=56 Sequence=3 ttl=254 time=20 ms
Reply from 10.0.2.2: bytes=56 Sequence=4 ttl=254 time=30 ms
Reply from 10.0.2.2: bytes=56 Sequence=5 ttl=254 time=30 ms

--- 10.0.2.2 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/28/30 ms

技术图片

 

缺省路由配置,ip route-static  0.0.0.0 0 nextHop

[Huawei]ip route-static 0.0.0.0 0 10.0.13.1

 

路由器静态IP的配置及其备份静态路由缺省路由

标签:ping命令   tran   add   out   缺省   user   tin   oss   http   

原文地址:https://www.cnblogs.com/dfQi/p/11650838.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!