实战 Ubuntu电信网通双线双IP双网卡配置

公司的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

 

参考资料:

http://www.lukexp.com/?p=10

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值