公司的Web服务器搬到了双线机房,同时接了电信和网通两根线,各自有各自IP地址。
域名通过DNSPod (https://www.dnspod.com/,在此特别感谢dnspod)做了智能解析
服务器配置如下:
The everonment:
Server Ubuntu 8.04 server
TEL IP: 222.73.178.212 netmask:255.255.255.128 gateway:222.73.178.129
CNC IP: 112.65.242.60 netmask:255.255.255.240 gateway:112.65.242.49
1.configure the network
$ sudo vim /etc/network/interfaces
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address 222.73.178.212
netmask 255.255.255.128
#network 211.152.56.128
#broadcast 211.152.56.255
gateway 222.73.178.129
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 202.96.209.133
dns-search bucu
auto eth1
iface eth1 inet static
address 112.65.242.60
netmask 255.255.255.240
Save and exit and the restart the network
$ sudo /etc/init.d/networking restart
Add two route tables for tel and cnc
$ sudo vim /etc/iproute2/rt_tables
252 tel
251 cnc
Save and exit
Add route rule
$ sudo ip route flush table tel
$ sudo ip route add default via 222.73.178.129 dev eth0 src 222.73.178.212 table tel
$ sudo ip route add from 222.73.178.212 table tel
$ sudo ip route flush table cnc
$ sudo ip route add default via 112.65.242.49 dev eth1 src 112.65.242.60 table cnc
$ sudo ip rule add from 112.65.242.60 table cnc
Add the commands above to networking start file
$ sudo vim /etc/init.d/networking
ip route flush table tel
ip route add default via 222.73.178.129 dev eth0 src 222.73.178.212 table tel
ip rule add from 222.73.178.212 table tel
ip route flush table cnc
ip route add default via 112.65.242.49 dev eth1 src 112.65.242.60 table cnc
ip rule add from 112.65.242.60 table cnc
exit 0
参考资料: