1.首先查看一下本机的路由 route -n 2.比如我们添加两条静态路由,访问192.168.142.100时通过192.168.142.10:访问192.168.142.200时通过192.168.142.20 vim /etc/sysconfig/network-scripts/-route-eth0 添加如下信息: 192.168.142.100/32 via 192.168.142.10 192.168.142.200/32 via 192.168.142.20 保存并退出.
1. #ifconfig 注意 eth0为你要配置的interfase 2. #vi /etc/network/interfaces # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo ifa
本文摘取自 Centos7系统配置上的变化(二)网络管理基础 一.ip route显示和设定路由 1.显示路由表 [root@centos7 ~]# ip route show default via 192.168.150.254 dev enp0s3 proto static metric 1024 192.168.150.0/24 dev enp0s3 proto kernel scope link src 192.168.150.110 太难看了,格式化一下(显示的是默认网关和局域网路由
查看路由表 ip route show|column -t route -n 永久添加路由 vim /etc/sysconfig/network-scripts/route-ens224 via 172.20.35.254 via dev ens224 重启网络生效 systemctl restart network