linux運維及配置工作中,常常會用到雙網(wǎng)卡綁定,少數(shù)幾臺服務器的配置還好,如果是需要配置幾十甚至上百臺,難免會枯燥乏味,易于出錯,我編寫了這個雙網(wǎng)卡綁定的輔助腳本,可傻瓜式地完成linux雙網(wǎng)卡綁定工作,當然,該腳本主要還是用于小批量的系統(tǒng)配置,如需配置大量的服務器,可提取腳本中的bonding函數(shù),稍作修改即可,你值得一試!
1.適用范圍
該shell腳本可在以下linux系統(tǒng)創(chuàng)建多個綁定網(wǎng)卡,用于生產環(huán)境沒問題的:
Redhat 5.x CentOS 5.x Kylin 3.x KUX 2.x2.腳本特點
---------------------------------------------------- Network Configuration Assistant ----------------------------------------------------The information you have entered:First NIC :eth0Second NIC :eth1bond name :bond1IP address :192.168.56.11netmask :255.255.255.0bonding_mode :mode=1primary NIC :none----------------------------------------------Pls make sure its OK[y/n]:y
如上,腳本在使用過程中,會依次提示輸入需要綁定的子網(wǎng)卡名稱、綁定網(wǎng)卡名稱、IP地址和子網(wǎng)掩碼、綁定模式、是否指定主網(wǎng)卡,并主動對系統(tǒng)中可用網(wǎng)卡進行識別并列出,供用戶選擇,同時會判斷輸入的各項信息的正確性,保障雙網(wǎng)卡綁定順利進行。
3.使用說明
首先將腳本上傳至linux系統(tǒng)任意目錄下,使用root用戶執(zhí)行:
[root@node1 tmp]# sh bonding_v2.0.sh ---------------------------------------------------- Network Configuration Assistant ---------------------------------------------------- 4 network cards available:eth0 eth1 eth2 eth3----------------------------------------------Please enter the First NIC:_
首先腳本會列出系統(tǒng)中有多少可用網(wǎng)卡,并提示輸入需要綁定的第一塊子網(wǎng)卡的名稱,這里輸入eth2。
無需擔心輸入錯誤,輸入重復等問題,腳本會自動判斷你的輸入信息是否正確。
---------------------------------------------------- Network Configuration Assistant ----------------------------------------------------4 network cards available:eth0 eth1 eth2 eth3The information you have entered:First NIC : eth2----------------------------------------------Please select the second NIC:_
接著輸入需要綁定的第二塊網(wǎng)卡的名稱eth3,如果輸入錯誤會出現(xiàn)相應的提示,比如錯輸入為eth8,會提示需要重新輸入:
---------------------------------------------------- Network Configuration Assistant ----------------------------------------------------4 network cards available:eth0 eth1 eth2 eth3The information you have entered:First NIC : eth2----------------------------------------------eth8 is not available,Please enter another one.Please select the second NIC:_
正確輸入需要綁定的第二塊網(wǎng)卡eth3后,如果linux系統(tǒng)中之前不存在綁定網(wǎng)卡,則默認第一個綁定網(wǎng)卡的名稱為bond0,如果系統(tǒng)中存在綁定網(wǎng)卡,腳本會提示輸入bondN(N為數(shù)字):
---------------------------------------------------- Network Configuration Assistant ----------------------------------------------------The information you have entered:First NIC : eth2Second NIC : eth3bond name : bond0----------------------------------------------The default first bond name is -- bond0.Please enter an IP address:_
新聞熱點
疑難解答
圖片精選