CentOS雙網卡雙IP設置 系統環境:CentOS Linux 網絡環境: 兩個IP地址,10.4.34.31和10.4.35.31,掩碼是255.255.255.0, 這兩個子網的網關地址分別是10.4.34.1和10.4.35.1。 1. 爲網卡eth0配置ip地址10.4.34.31,爲網卡eth1配置ip地址爲10.4.35.31配置文件爲: /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth1 2. 配置默認網關爲任意一個。這個默認網關,決定了系統主動去使用網絡時,使用的接口。 配置文件:/etc/sysconfig/network 3. 編輯路由表 a、修改/etc/iproute2/rt_tables,添加內容: 252 net2 251 net3 b、修改/etc/rc.local,添加原路返回路由: ip route flush table net2 ip route add default via 10.4.34.1 dev eth0 src 10.4.34.31 table net2 ip rule add from 10.4.34.31 table net2 ip route flush table net3 ip route add default via 10.4.35.1 dev eth1 src 10.4.35.31 table net3 ip rule add from 10.4.35.31 table net3 參考:http://www.lartc.org/LARTC-zh_CN.GB2312.pdf