//服务器两块网卡 eth0:192.168.0.100 eth1:172.168.1.10 [root@localhost ~]# ifconfig|grep inet|grep -v inet6|grep -v 127.0.0.1 inet addr:192.168.0.100 Bcast:192.168.0.255 Mask:255.255.255.0 inet addr:172.168.1.10 Bcast:172.168.1.255 Mask:255.255.255.0 配置默认网关为任意一个,系统主动去使用网络时选择的出口 [root@localhost log]# more /etc/sysconfig/network NETWORKING=yes HOSTNAME=localhost.localdomain GATEWAY=192.168.0.1 //添加网关 两块网卡需要调整路由,否则链接不上 //添加到/etc/rc.local [root@localhost ~]# more net.sh ip route flush table tel ip route add default via 192.168.0.1 dev eth0 src 192.168.0.100 table tel ip rule add from 192.168.0.100 table tel ip route flush table cnc ip route add default via 172.168.1.1 dev eth1 src 172.168.1.10 table cnc ip rule add from 172.168.1.10 table cnc 编辑路由表 [root@localhost ~]# vi /etc/iproute2/rt_tables 200 tel 300 cnc //查看路由表 route -n ip route list netstat -rn [root@localhost ~]# ip route list 192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.100 172.168.1.0/24 dev eth1 proto kernel scope link src 172.168.1.10 169.254.0.0/16 dev eth0 scope link metric 1002 169.254.0.0/16 dev eth1 scope link metric 1003 default via 192.168.0.1 dev eth0 [root@localhost ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 172.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1 0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0 (责任编辑:IT) |