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

相關文章
相關標籤/搜索