debian与centos上单网卡配置多个IP

debian与contos单网卡绑定多个IP,若是是远程操做的话(如:ssh),切记要重启网卡的时候要 || ifup eth0
不然第二个IP或第二个配置文件有问题将致使网络中断,个人debian就断了…. 服务器

  1. root@debian:/etc/network# cat interfaces
  2. # This file describes the network interfaces available on your system
  3. # and how to activate them. For more information, see interfaces(5).
  4.  
  5. # The loopback network interface
  6. auto lo
  7. iface lo inet loopback
  8.  
  9. # The primary network interface
  10. allow-hotplug eth0
  11. iface eth0 inet static
  12.         address 10.0.0.212
  13.         netmask 255.255.255.0
  14.         network 10.0.0.0
  15.         broadcast 10.0.0.255
  16.         # dns-* options are implemented by the resolvconf package, if installed
  17.         dns-nameservers 10.0.0.1
  18. allow-hotplug eth0:1
  19. iface eth0:1 inet static
  20.         address 10.0.0.145
  21.         netmask 255.255.255.0
  22.         network 10.0.0.0
  23.         broadcast 10.0.0.255
  24. ### 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来作,这里就不献丑了。 less

相关文章
相关标签/搜索