linux删除路由的方法 您所在的位置:网站首页 网段规则 linux删除路由的方法

linux删除路由的方法

2024-06-24 21:34| 来源: 网络整理| 查看: 265

临时删除路由

[Tue Jun 23 02:24:36][20994][root@atpd-exa-2ulap1:~][7]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.1.24.1 0.0.0.0 UG 0 0 0 bondeth0 10.1.24.0 0.0.0.0 255.255.255.0 U 0 0 0 bondeth0 129.213.240.204 169.254.100.1 255.255.255.255 UGH 0 0 0 veth0 129.213.242.217 169.254.100.1 255.255.255.255 UGH 0 0 0 veth0 134.70.0.0 169.254.100.1 255.255.128.0 UG 0 0 0 veth0 134.70.7.254 169.254.100.1 255.255.255.255 UGH 0 0 0 veth0 169.254.100.0 0.0.0.0 255.255.255.224 U 0 0 0 veth0 169.254.200.0 0.0.0.0 255.255.255.252 U 0 0 0 eth0 172.16.64.48 169.254.100.1 255.255.255.240 UG 0 0 0 veth0 172.16.64.152 169.254.100.1 255.255.255.248 UG 0 0 0 veth0 192.168.132.0 0.0.0.0 255.255.252.0 U 0 0 0 clib0 192.168.132.0 0.0.0.0 255.255.252.0 U 0 0 0 clib1 192.168.136.0 0.0.0.0 255.255.248.0 U 0 0 0 stib0 192.168.136.0 0.0.0.0 255.255.248.0 U 0 0 0 stib1 [Tue Jun 23 02:24:44][20994][root@atpd-exa-2ulap1:~][0]# route del -net 134.70.0.0 netmask 255.255.128.0 [Tue Jun 23 02:26:43][20994][root@atpd-exa-2ulap1:~][0]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.1.24.1 0.0.0.0 UG 0 0 0 bondeth0 10.1.24.0 0.0.0.0 255.255.255.0 U 0 0 0 bondeth0 129.213.240.204 169.254.100.1 255.255.255.255 UGH 0 0 0 veth0 129.213.242.217 169.254.100.1 255.255.255.255 UGH 0 0 0 veth0 134.70.7.254 169.254.100.1 255.255.255.255 UGH 0 0 0 veth0 169.254.100.0 0.0.0.0 255.255.255.224 U 0 0 0 veth0 169.254.200.0 0.0.0.0 255.255.255.252 U 0 0 0 eth0 172.16.64.48 169.254.100.1 255.255.255.240 UG 0 0 0 veth0 172.16.64.152 169.254.100.1 255.255.255.248 UG 0 0 0 veth0 192.168.132.0 0.0.0.0 255.255.252.0 U 0 0 0 clib0 192.168.132.0 0.0.0.0 255.255.252.0 U 0 0 0 clib1 192.168.136.0 0.0.0.0 255.255.248.0 U 0 0 0 stib0 192.168.136.0 0.0.0.0 255.255.248.0 U 0 0 0 stib1

查看服务器路由方法:在root用户下执行route命令

1.通过命令修改默认路由。此种方式临时生效,重启网卡后默认路由会还原

route del default(使用两次,两条默认路由全部删除)。 route add default gw 192.168.71.1(即再重新添加一次正确的路由)

2、通过命令添加、删除明细路由。此种方式临时生效,重启网卡后默认路由会还原 route add -net 192.0.0.0 netmask 255.0.0.0 gw 192.168.207.129 route del -net 192.0.0.0 netmask 255.0.0.0

3、添加永久默认路由 在/etc/sysconfig/network-scripts/ifcfg-bond0里添加到文件末尾,格式如下 GATEWAY=10.96.207.161 这种方式用于添加默认网关了

4、添加永久明细路由,写入/etc/rc.loacl 将route add -net 192.0.0.0 netmask 255.0.0.0 gw 192.168.207.129写入/etc/rc.local文件中,这样在系统启动的时候会自动加入相关的路由设置。如果你手动重启了网络服务或网络服务自动重启,那么路由就失效了,会导致网络不通,业务出问题。这个时候你不得不重新加载这个文件,这个方法不是非常的不推荐。

5、添加永久明细路由,写入/etc/sysconfig/static-routes文件 默认在/etc/sysconifg目录中是没有这个文件的,需要我们手工创建,对这个文件的调用在下面: /etc/init.d/network: 159 # Add noninterface-specific static-routes. 160 if [ -f/etc/sysconfig/static-routes ]; then 161 grep “^any”/etc/sysconfig/static-routes | while read ignore args ; do 162 /sbin/route add -$args 163 done 164 fi /etc/sysconfig/static-routes: any net 192.168.1.0/24 gw 192.168.1.24 any net 192.168.2.0 netmask 255.255.255.0 gw 192.168.2.1 这种方式的话,和rc.local比较而言,比较实用,还比如nfs,这个路由的生效时间是在网络服务network启动的时候生效的,而其他的一些网络相关服务都是在网络服务启动成功之后再启动的,所以能够保证网络链路的通畅。

6、添加路由后重启网络服务时报错SIOCADDRT: no such process 原因一般是配置的IP地址有问题,注意检查ip与gateway是不是在一个网段内,还有是不是有拼写错误



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有