linux操作系統(tǒng)下雙網(wǎng)卡綁定有七種模式∫蛲矗現(xiàn)在一般的企業(yè)都會(huì)使用雙網(wǎng)卡接入燕耿,這樣既能添加網(wǎng)絡(luò)帶寬低千,同時(shí)又能做相應(yīng)的冗余猪腕,可以說是好處多多冗澈。而一般企業(yè)都會(huì)使用linux操作系統(tǒng)下自帶的網(wǎng)卡綁定模式,當(dāng)然現(xiàn)在網(wǎng)卡產(chǎn)商也會(huì)出一些針對(duì)windows操作系統(tǒng)網(wǎng)卡管理軟件來(lái)做網(wǎng)卡綁定(windows操作系統(tǒng)沒有網(wǎng)卡綁定功能 需要第三方支持)码撰,一共有其中方式渗柿,其中比較長(zhǎng)用的是0/1/6:
雙網(wǎng)卡綁定的前提:安裝“bridge-utils”軟件包
[root@centos7 ~]# yum -y install bridge-utils
網(wǎng)卡綁定案例,先做綁定脖岛,然后再把綁定后的網(wǎng)卡配置成橋接:
1.1:第一組配置朵栖,將eth1和eth5綁定為bond0:
1.1.1:先創(chuàng)建bond0配置那文件步驟及內(nèi)容如下:
[root@linux-host1 ~]# cd /etc/sysconfig/network-scripts/
[root@linux-host1 network-scripts]# cp ifcfg-eth0 ifcfg-bond0
[root@linux-host1 network-scripts]# cat ifcfg-bond0 #內(nèi)容如下:
BOOTPROTO=static
NAME=bond0
DEVICE=bond0
ONBOOT=yes
BONDING_MASTER=yes
BONDING_OPTS="mode=1 miimon=100" #指定綁定類型為1及鏈路狀態(tài)監(jiān)測(cè)間隔時(shí)間
BRIDGE=br0 #橋接到br0
1.1.2:配置br0:
TYPE=Bridge
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=br0
DEVICE=br0
ONBOOT=yes
IPADDR=X.X.X.X
NETMASK=255.255.255.0
GATEWAY=X.X.X.X
1.1.3:eth1配置:
[root@linux-host1 network-scripts]# vim ifcfg-eth1
BOOTPROTO=static
NAME=eth1
DEVICE=eth1
ONBOOT=yes
NM_CONTROLLED=no
MASTER=bond0
USERCTL=no
SLAVE=yes
1.1.4:eth5的配置:
[root@linux-host1 network-scripts]# cp ifcfg-eth1 ifcfg-eth5
[root@linux-host1 network-scripts]# vim ifcfg-eth5
BOOTPROTO=static
NAME=eth5
DEVICE=eth5
ONBOOT=yes
NM_CONTROLLED=no
MASTER=bond0
USERCTL=no
SLAVE=yes
1.1.5:重啟網(wǎng)絡(luò)服務(wù):
[root@linux-host1 network-scripts]# systemctl restart network
1.1.6:驗(yàn)證網(wǎng)絡(luò)是否正常:
[root@linux-host1 network-scripts]# ping www.baidu.com
PING www.a.shifen.com (61.135.169.125) 56(84) bytes of data.
64 bytes from 61.135.169.125: icmp_seq=1 ttl=128 time=6.17 ms
64 bytes from 61.135.169.125: icmp_seq=2 ttl=128 time=10.3 ms
64 bytes from 61.135.169.125: icmp_seq=3 ttl=128 time=5.36 ms
64 bytes from 61.135.169.125: icmp_seq=4 ttl=128 time=6.74 ms
64 bytes from 61.135.169.125: icmp_seq=5 ttl=128 time=5.71 ms
1.1.7:可以驗(yàn)證當(dāng)前是綁定在哪一塊網(wǎng)卡上的:
[root@linux-host1 ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth1 #備份鏈路網(wǎng)卡
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 18:66:da:f3:34:e5
Slave queue ID: 0
Slave Interface: eth5
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0a:f7:99:ba:d1
Slave queue ID: 0
1.2:第二組配置,將eth2和eth6綁定為bond1:
1.2.1:創(chuàng)建bond1配置文件:
[root@linux-host1 network-scripts]# cp ifcfg-bond0 ifcfg-bond1
[root@linux-host1 network-scripts]# vim ifcfg-bond1
BOOTPROTO=static
NAME=bond1
DEVICE=bond1
TYPE=Bond
BONDING_MASTER=yes
BOOTPROTO=static
NAME=bond1
ONBOOT=yes
BONDING_OPTS="mode=1 miimon=100"
BRIDGE=br1
1.2.2:配置br1:
TYPE=Bridge
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=br1
DEVICE=br1
ONBOOT=yes
IPADDR=X.X.X.X
NETMASK=255.255.255.0
GATEWAY=X.X.X.X
DNS1=X.X.X.X
1.2.3:eth2的配置:
[root@linux-host1 network-scripts]# vim ifcfg-eth2
BOOTPROTO=static
NAME=eth2
DEVICE=eth2
ONBOOT=yes
NM_CONTROLLED=no
MASTER=bond1
USERCTL=no
SLAVE=yes
1.2.4:eth6的配置:
[root@linux-host1 network-scripts]# vim ifcfg-eth6
BOOTPROTO=static
NAME=eth6
DEVICE=eth6
ONBOOT=yes
NM_CONTROLLED=no
MASTER=bond1
USERCTL=no
SLAVE=yes
1.2.5:重啟網(wǎng)絡(luò)服務(wù):
[root@linux-host1 network-scripts]# systemctl restart network
1.2.6:測(cè)試內(nèi)網(wǎng)網(wǎng)絡(luò)是否正常:
[root@linux-host1 network-scripts]# ping 192.168.20.12
PING 192.168.20.12 (192.168.20.12) 56(84) bytes of data.
64 bytes from 192.168.20.12: icmp_seq=1 ttl=64 time=1.86 ms
64 bytes from 192.168.20.12: icmp_seq=2 ttl=64 time=0.570 ms
64 bytes from 192.168.20.12: icmp_seq=3 ttl=64 time=0.410 ms
1.3:設(shè)置開機(jī)啟動(dòng):
[root@linux-host1 network-scripts]# vim /etc/rc.d/rc.local
ifenslave eth1 eth5
ifenslave eth2 eth6
[root@linux-host1 network-scripts]# chmod a+x /etc/rc.d/rc.local