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

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

如下图,

首先进入路由器的命令视图,(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

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

时间: 2024-10-16 14:00:40

路由器静态IP的配置及其备份静态路由缺省路由的相关文章

4个路由静态IP地址配置

配置接口IP地址并通过静态路由 ,实现全网互通.在4个 路由器上配置IP地址路由器配置好的IP地址路由器静态IP地址配置,4个路由同样的操作步骤,IP地址不同.4台pc机都能互相ping通 原文地址:https://blog.51cto.com/14310238/2388151

ubuntn 虚拟机NAT 静态IP 网络配置

在虚拟机安装ubuntu12.04自动获取IP 一切都没有问题 ssh连接也正常.关机重启后郁闷的发现网络已经不通了,于是开始了以下的摸索. 1.配置静态IP 网关: ip段: 命令: Vim /etc/network/interface auto lo iface lo inet loopback auto eth0 # Assgin static IP by eric on 26-SEP-2012 iface eth0 inet static address 192.168.91.200 #

路由器的基本原理与配置命令(静态路由和默认路由)

路由器工作在OSI参考模型的网络层,它的重要作用是为数据包选择最佳路径,最终送达目的地.那么路由器是怎样选择路径的呢?如果主机A要和主机B通信,就需要一种方法判断源主机和目标主机所经过的最佳路径,从而进行数据转发,这就是路由技术. 路由器的工作原理 路由器是如何进行数据转发的呢?就像我们去一个地方,他的脑子里一定会有一张地图,在每个路由器的内部也有一张地图,这张地图就是路由表.在路由表中,包含了每个路由器所掌握的所有目的地的网络地址,以及通过此路由器到达这些网络的最佳路径.这个最佳路径是指路由器

Ubuntu Server 12.04 静态IP简洁配置

PS:很长时间没使用Ubuntu了,刚才安装个Ubuntu Server 12.04做测试.Ubuntu的网络设置跟Redhat系是不一样的,配置IP时发现跟以前的Ubuntu桌面版本也有所不同,记录如下: 1.配置静态IP地址: # vim /etc/network/interfaces 原内容有如下4行:auto loiface lo inet loopback auto eth0iface eth0 inet dhcp 以上表示默认使用DHCP分配IP,修改为如下: auto loifac

【转】Ubuntu Server 12.04 静态IP简洁配置

原文网址:http://blog.csdn.net/njchenyi/article/details/8715417 1.配置静态IP地址: # vim /etc/network/interfaces 原内容有如下4行:auto loiface lo inet loopback auto eth0iface eth0 inet dhcp 以上表示默认使用DHCP分配IP,修改为如下: auto loiface lo inet loopback # The primary network inte

Linux学习笔记(五)---centos7系统静态IP地址配置

上节我们把ip地址使用dhclient自动获取ip,但是有时重启虚拟机ip地址会变为其他的.导致xshell连接时又要修改配置文件,为此我们把ip地址给改为静态IP.具体操作如下:1.打开网卡配置文件vi /etc/sysconfig/network-scripts/ifcfg-ens332.把DHCP修改为static,把开机启动修改为yes3.再把IP地址.子网掩码.默认网关.DNS配置上4.保存退出(vi的操作,请参考前期分享的vim使用).5.重启网络服务至此,完成IP静态配置. 原文地

VMware中对Linux虚拟机的网络配置静态IP的配置

前言 踏出象牙塔,进入公司,由于公司的所有产品都是Linux下的,必然自己这段时间需要在自己的工作机器先学习一下.项目代码是用Source Insight进行查看的,总是Ctrl + Alt的切来切去不方便,故Xshell出场了.这就引发了一个问题,就是如何在VMware的Linux虚拟机中配置静态IP? 检查 使用公司的工作机器----系统WIN7,首次安装VMware 12 + rhel-6.5.继而出现以下问题 问题1: 没有修改过虚拟网卡连接模式(NAT,桥接等),在win中的虚拟网卡无

CentOs下NAT模式静态IP网络配置

虚拟机安装可以参考:https://www.cnblogs.com/willingchen/p/9069477.html. 一.VM部分设置 首先我们来配置VM的网络配置,首先打开VMware的编辑找到虚拟网络编辑器 然后点击更改设置后,选择NAT模式 接下来设置好子网ip(一般为xxx.xxx.xxx.0)和子网掩码(255.255.255.0),然后点击DHCP 接下来设置好DHCP(设置到和子网的同一个IP段即可) 点击确定后,设置NAT设置 设置NAT的网关,一般子网ip我们设置为xxx

Ubuntu Server 12.04(14.04) 静态IP简洁配置

1.配置静态IP地址: # vim /etc/network/interfaces 原内容有如下4行:auto loiface lo inet loopback auto eth0iface eth0 inet dhcp 以上表示默认使用DHCP分配IP,修改为如下: auto loiface lo inet loopback # The primary network interfaceauto eth0#iface eth0 inet dhcp iface eth0 inet statica