CentOS7添加路由
Posted 没刮胡子
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS7添加路由相关的知识,希望对你有一定的参考价值。
查看路由情况
ip route show
添加路由(临时)
ip route add 192.168.8.0/24 via 192.168.8.1 dev em1
ip route add 10.0.0.0/24 via 10.0.0.1 dev em2
删除路由
ip route del 10.0.0.0/24 via 10.0.0.1 dev em2
ip route del 169.254.0.0/16
ip route del default via 10.0.0.1
添加静态路由
vim /etc/sysconfig/network-scripts/route-em1
192.168.8.0/24 via 192.168.8.1 dev em1
vim /etc/sysconfig/network-scripts/route-em2
10.0.0.0/24 via 10.0.0.1 dev em2
重启
systemctl restart network
修改网卡2配置
vim /etc/sysconfig/network-scripts/ifcfg-em2
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=em2
UUID=7df972a2-d815-40ac-9b7f-87b860c6648f
DEVICE=em2
ONBOOT=yes
IPADDR=10.0.0.10
PREFIX=24
GATEWAY=10.0.0.1
DEFROUTE=no
修改网卡1配置
vim /etc/sysconfig/network-scripts/ifcfg-em1
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=em1
UUID=63add7e5-4cb6-4adb-a672-4290c1de3bac
DEVICE=em1
ONBOOT=yes
IPADDR=192.168.8.10
PREFIX=24
GATEWAY=192.168.8.1
DNS1=114.114.114.114
重启网络
systemctl restart network
以上是关于CentOS7添加路由的主要内容,如果未能解决你的问题,请参考以下文章