debian與centos上單網卡配置多個IP

來源:互聯網
上載者:User

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.