debian与contos单网卡绑定多个IP,如果是远程操作的话(如:ssh),切记要重启网卡的时候要 || ifup eth0
否则第二个IP或第二个配置文件有问题将导致网络中断,我的debian就断了….
- root@debian:/etc/network# cat interfaces
- # This file describes the network interfaces available on your system
- # and how to activate them. For more information, see interfaces(5).
- # The loopback network interface
- auto lo
- iface lo inet loopback
- # The primary network interface
- allow-hotplug eth0
- iface eth0 inet static
- address 10.0.0.212
- netmask 255.255.255.0
- network 10.0.0.0
- broadcast 10.0.0.255
- # dns-* options are implemented by the resolvconf package, if installed
- dns-nameservers 10.0.0.1
- allow-hotplug eth0:1
- iface eth0:1 inet static
- address 10.0.0.145
- netmask 255.255.255.0
- network 10.0.0.0
- broadcast 10.0.0.255
- ### for wlan by evan
#auto wlan0
#allow-hotplug wlan0
#iface wlan0 inet dhcp
#wireless-essid Pie-58
#wireless-key lailailai
debian下关于单网卡绑定双ip的问题
最近需要弄一台服务器,分别分配了网通和电信的ip,搞出了很多问题,也长见识了。和大家分享一下。单网卡绑定双ip,网上很多做法,大家都在转载,没人去测试它的真伪,会害死人的,尤其是机房很远的童鞋们。
具体做法$ sudo vi /etc/network/interfaces
auto lo eth0iface lo inet loopbackiface eth0 inet staticaddress 192.168.10.56netmask 255.255.254.1gateway 192.168.10.1
auto eth0:0address 192.168.11.250netmask 255.255.254.0gateway 192.168.10.52
$ sudo /etc/init.d/networking restart重启网络
只是网上流传的做法,但是不知道大家做过测试没有,这样是行不通的的,问题在eth0:0,如果一个网卡有2个默认网关,将会不转发数据,具体原理想想ip路由过程应该可以明白。
因此正确的做法是,去掉eth0:0中的gateway,然后在route那里添加gateway就行了,怎么添加,请看我以前的帖子。也可以用iptable来做,这里就不献丑了。
来源:oschina
链接:https://my.oschina.net/u/164475/blog/116170