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 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來做,這裡就不獻丑了。