CentOS 7 bonding模式雙網卡綁定


1.1    查看系統內核是否支持bonding

[root@cobbler-node1 ~]# cat /boot/config-3.10.0-693.el7.x86_64 | grep -i bonding
CONFIG_BONDING=m

1.2    備份系統自帶的網卡配置文件,以及創建bond0網卡配置文件

[root@cobbler-node1 ~]# cd /etc/sysconfig/network-scripts
[root@cobbler-node1 network-scripts]# pwd
/etc/sysconfig/network-scripts
[root@cobbler-node1 network-scripts]# cp -a ifcfg-eth0 ifcfg-eth0.bak
[root@cobbler-node1 network-scripts]# cp -a ifcfg-eth1 ifcfg-eth1.bak
[root@cobbler-node1 network-scripts]# cp -a ifcfg-eth0.bak ifcfg-bond0

1.3修改系統eth0、eth1、bond0網卡配置文件

[root@cobbler-node1 network-scripts]# vi ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=none
DEVICE=eth0
ONBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes
[root@cobbler-node1 network-scripts]# vi ifcfg-eth1
TYPE=Ethernet
BOOTPROTO=none
DEVICE=eth1
ONBOOT=yes
USERCTL=no
MASTER=bond0
SLAVE=yes
[root@cobbler-node1 network-scripts]# vi ifcfg-bond0 
TYPE=Bond
BOOTPROTO=none
DEVICE=bond0
ONBOOT=yes
IPADDR=10.129.49.240
NETMASK=255.255.255.0
GATEWAY=10.129.49.1
DNS1=10.112.15.30
DNS2=10.112.15.33
USERCTL=no

1.4    將eth0、eth1網卡配置文件合並顯示

[root@cobbler-node1 network-scripts]# paste ifcfg-eth0 ifcfg-eth1
TYPE=Ethernet   TYPE=Ethernet
BOOTPROTO=none  BOOTPROTO=none
DEVICE=eth0     DEVICE=eth1
ONBOOT=yes      ONBOOT=yes
USERCTL=no      USERCTL=no    #控制用戶是否有修改網卡的權限,必須設置為no,只有root用戶才可以修改
MASTER=bond0    MASTER=bond0
SLAVE=yes       SLAVE=yes

1.5    對比eth0、eth1網卡配置文件不同內容

[root@cobbler-node1 network-scripts]# diff ifcfg-eth0 ifcfg-eth1     
3c3
< DEVICE=eth0
---
> DEVICE=eth1

1.6    在/etc/modprobe.d/目錄下創建bonding.conf(網卡綁定模式)配置文件

[root@cobbler-node1 network-scripts]# echo -e "alias bond0 bonding\noptions bond0 mode=6 miimon=100" >> /etc/modprobe.d/bonding.conf
[root@cobbler-node1 network-scripts]# cat /etc/modprobe.d/bonding.conf 
alias bond0 bonding
options bond0 mode=6 miimon=100    
注意: #mode=6代表負載均衡;兩塊網卡同時工作,增加網絡帶寬,不需要依賴物理交換機設置 #mode=1代表主備切換;只有一塊網卡處於活動狀態,活動網卡故障切換到備用網卡 #miimon=100代表網絡鏈路檢測頻率100ms檢查一次,如果出現問題則切換到備用網卡

1.7    執行modprobe bonding命令更新加載bonding模塊,使其系統支持網卡bonding

[root@cobbler-node1 network-scripts]# modprobe bonding
#驗證bonding模塊是否加載成功,出現如下結果則證明加載成功
[root@cobbler-node1 network-scripts]# lsmod | grep bonding
bonding               145728  0

1.8    重啟系統網絡服務

[root@cobbler-node1 network-scripts]# systemctl restart network

1.9    查看網卡綁定的模式以及綁定的網卡狀態信息

[root@cobbler-node1 network-scripts]# cat /proc/net/bonding/bond0 
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 28:6e:d4:88:ce:5d
Slave queue ID: 0

Slave Interface: eth1
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: 28:6e:d4:88:ce:5e
Slave queue ID: 0

 1.10    查看系統網絡信息,驗證綁定成功

[root@cobbler-node1 network-scripts]# ifconfig
bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500
        inet 10.129.49.240  netmask 255.255.255.0  broadcast 10.129.49.255
        inet6 fe80::2a6e:d4ff:fe88:ce5d  prefixlen 64  scopeid 0x20<link>
        ether 28:6e:d4:88:ce:5d  txqueuelen 1000  (Ethernet)
        RX packets 1675775  bytes 126050576 (120.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3432  bytes 496778 (485.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        ether 28:6e:d4:88:ce:5d  txqueuelen 1000  (Ethernet)
        RX packets 837774  bytes 63015040 (60.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1718  bytes 237790 (232.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        ether 28:6e:d4:88:ce:5d  txqueuelen 1000  (Ethernet)
        RX packets 838224  bytes 63053418 (60.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1714  bytes 258988 (252.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 8  bytes 584 (584.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8  bytes 584 (584.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM