2015年11月8日 星期日

Linux Nic Config Bond 網路卡 bond

網路卡 bond

鳥哥那邊很多資訊

https://mieklefield.wordpress.com/2011/12/02/network-channel-bonding-for-failover/



如果使用X window 模式 需關閉 NetworkManager
這個會害死你



chkconfig NetworkManager --level 2345 off




1  載入 bonding 模組,並將介面取名為 bond0
在 CentOS 5.x 以後,Linux 的模組對應表已經寫入到 /etc/modprobe.d/*.conf 檔案內了~這個目錄內的檔名是可以自己取的,不過副檔名必須是 .conf 就是了。 我們取個名為 bonding.conf 的檔案好了,內容這樣寫即可:

[root@centos ~]# vim /etc/modprobe.d/bonding.conf
alias bond0 bonding
# bond0 為我們需要的介面, bonding 則是 Linux 的核心模組之意!



2 修改 bond0 所管理的各個實體網卡設定檔:
在鳥哥的這個案例中,Linux 系統的 eth0 為對 Internet 連線的介面,所以 bond0 管理的介面有 eth1, eth2, eth3 這 3 個!那這三張網卡的設定檔該如何修改呢? 很簡單,如底下這樣設定即可。(注意,被 bonding 所管理的各張網卡,習慣上,我們都會稱之為 slave 網卡!)
[root@centos ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE="eth1"
HWADDR="00:1B:21:3E:8C:47"   < 可以不用給予==某些情況下,可能要對應好網卡卡號,才能夠讓網卡正確取得代號
NM_CONTROLLED="yes"
ONBOOT="yes"
MASTER=bond0
SLAVE=yes
USERCTL=no
# 最重要的是那個 MASTER 與 SLAVE 兩個設定項目。且因為是受 bond0 管理,所以不需要網路參數。
# 至於 eth2, eth3 則是依樣畫葫蘆,這裡就不示範囉!自行修訂即可。

建立 bond0 新介面的設定檔:
現在開始,這 eth1~eth3 這 3 張網卡都是歸 bond0 所管,那當然要建立一個名為 ifcfg-bond0 的網路參數設定檔囉!鳥哥目前管理的這個教室的網域參數為 192.168.42.0/24 這一段,因此這樣設定我的伺服器:
[root@centos ~]# vim /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.42.254
NETMASK=255.255.255.0
BONDING_OPTS="miimon=100 mode=6"
TYPE=Unknown
IPV6INIT=no
# 重點是 BONDING_OPTS 這一串!mode=6 不用談,當然就是各個模式!這裡我們用 6 ,
# 至於那個 miimon 指的是『多久偵測一次各個 slave 網卡的連線狀態』的意思,
# 這個值的單位是『毫秒』,就是 10 的 -3 次方秒~1000毫秒為一秒~
# 也就是說,我們大約 0.1 秒就偵測一次每張網卡的狀態!據以進行網路容錯測試!



You must put following two command lines into /etc/rc.local when server boot
############################################################
/sbin/modprobe bonding
/sbin/service network restart
############################################################
load the bonding module, enter:
# modprobe bonding
Restart the networking service in order to bring up bond0 interface, enter:
# service network restart
############################################################

















沒有留言:

RHEL install EPEL

  https://www.linuxtechi.com/install-epel-repo-on-rhel-system/ EPEL dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest...