2021-05-12 14:32:11
RedHat6.5雙網絡卡bonding
2020-06-16 17:30:13
環境:RHEL 6.5
注意:此處的機器環境是3網絡卡,我用eth0連ssh的,但是一直掉...
需要關閉NetworkManager,並將其設定為開機不啟動(這個玩意兒真煩)
1. 建立bond0檔案:
vim /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
ONBOOT=yes
BOOTPROTO=static
TYPE=Ethernet
IPADDR=192.168.115.50
NETMASK=255.255.255.0
2. 修改網絡卡設定:
vim /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
USERCTL=no
vim /etc/sysconfig/network-scripts/ifcfg-eth2
DEVICE=eth2
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
USERCTL=no
3. 載入bond模組,在組態檔末尾新增引數
vim /etc/modprobe.d/dist.conf
-
alias bond0 bonding
options bond0 mode=0 miimon=100
解析:
mode 0表示為負載均衡模式,兩塊網絡卡都工作
mode 1表示冗餘模式,一塊是工作,一塊冗餘
miimon表示系統檢查間隔時間,單位是ms,
例如:每100ms檢查一次,當發現一條線路不通,就轉入另一條
4. 將bond0設定為開機自動載入
vim /etc/rc.local
ifenslave bond0 eth1 eth2
5. reboot ,之後使用ifconfig檢視bond0和eht1,eth2兩塊網絡卡的MAC地址是否相同
注意不管bond 0 還是bond 1,都是三者相同,因為在交換機的時候需要識別MAC然後傳送到對應的MAC上,不相同是不對的,
假如不相同,回去檢查NetworkManager是不是關了
來個標準的:
注意
[root@oratest0 ~]# ifconfig
bond0 Link encap:EthernetHWaddr00:0C:29:44:52:23
inet addr:192.168.115.50Bcast:192.168.115.255Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe44:5223/64Scope:Link
UP BROADCAST RUNNING MASTER MULTICAST MTU:1500Metric:1
RX packets:878 errors:0 dropped:0 overruns:0 frame:0
TX packets:349 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:81301(79.3KiB) TX bytes:58143(56.7KiB)
eth0 Link encap:EthernetHWaddr00:0C:29:44:52:19
inet addr:192.168.115.40Bcast:192.168.115.255Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe44:5219/64Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500Metric:1
RX packets:170 errors:0 dropped:0 overruns:0 frame:0
TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:15663(15.2KiB) TX bytes:746(746.0 b)
eth1 Link encap:EthernetHWaddr00:0C:29:44:52:23
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500Metric:1
RX packets:702 errors:0 dropped:0 overruns:0 frame:0
TX packets:175 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:65260(63.7KiB) TX bytes:27907(27.2KiB)
eth2 Link encap:EthernetHWaddr00:0C:29:44:52:23
UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500Metric:1
RX packets:176 errors:0 dropped:0 overruns:0 frame:0
TX packets:174 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:16041(15.6KiB) TX bytes:30236(29.5KiB)
lo Link encap:LocalLoopback
inet addr:127.0.0.1Mask:255.0.0.0
inet6 addr:::1/128Scope:Host
UP LOOPBACK RUNNING MTU:16436Metric:1
RX packets:10 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:840(840.0 b) TX bytes:840(840.0 b)
6. 檢視bond狀態,能實時檢視兩塊網絡卡的工作狀態
cat /proc/net/bonding/bond0
相關文章