方式1: 添加路由:route add -net 192.168.1.0/24 netmask 255.255.255.0 gw 192.168.1.1 [dev eth0] 删除路由:route del -net 192.168.1.0/24 netmask 255.255.255.0 gw 192.168.1.1 [dev eth0] 查看路由表信息:route -n 这种方式,服务器重启或者网卡重启就会失效,所以为了让服务器重启能自动生效,我们可以把路由设置放到/etc/rc.local配置文件里。 方式2:# cat /etc/sysconfig/network-scripts/bond0.route

ADDRESS0=10.0.0.0

NETMASK0=255.0.0.0

GATEWAY0=10.0.0.5

ADDRESS1=172.17.0.0

NETMASK1=255.255.0.0

GATEWAY1=10.0.0.5

ADDRESS2=172.18.0.0

NETMASK2=255.255.0.0

GATEWAY2=10.0.0.5 方式3:# cat /etc/sysconfig/network-scripts/route-eth2

10.240.240.19/32 via 10.240.180.1

10.240.241.20/32 via 10.240.180.1

10.240.242.21/32 via 10.240.180.1

10.240.243.22/32 via 10.240.180.1