debian與centos上單網卡配置多個IP 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 interfaceauto loiface lo inet loopback # The primary network interfaceallow-hotplug eth0iface 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.1allow-hotplug eth0:1iface 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 lailailaidebian下關於單網卡綁定雙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來做,這裡就不獻醜了。