centos7.2網卡綁定
查看硬件狀態
nmcli device status
1.關閉防火墻
systemctl status firewalld
systemctl stop firewalld
systemctl disable firewalld
systemctl mask firewalld
2.關閉selinux
sed -i ‘s/SELINUX=.*/SELINUX=disabled/‘ /etc/selinux/config
getenforce 0
3.關閉sshDNS解析
sed -i ‘s/#UseDNS yes/UseDNS no/‘ /etc/ssh/sshd_config
systemctl restart sshd.service
4.加載模塊
centos7默認沒有加bonding內核模板,加載方式
modprobe --first-time bonding
查看是否加載成功
lsmod | grep bonding 或者 modinfo bonding
5.配置nameserver
echo ‘nameserver 218.85.157.99‘ >> /etc/resolv.conf
6.配置bond0網卡
備份舊的網卡
mv ifcfg-ens192{,.bak}
7.配置網卡bond0
nmcli conn add type bond con-name bond0 ifname bond0 mode active-backup [主備]
或者
nmcli conn add type bond con-name bond0 ifname bond0 mode balance-rr [輪詢]
8.配置eth0和eth1 要綁定網卡
nmcli conn add type bond-slave con-name eth0 ifname ens192 master bond0
nmcli conn add type bond-slave con-name eth1 ifname ens224 master bond0
網卡配置信息如下:
[root@www network-scripts]#ifcfg-eth0
cat <<EOF> /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
NAME=eth0
#UUID=f6b97d3b-0fee-44a7-8a7b-ef22268ac6c4
DEVICE=ens192
ONBOOT=yes
MASTER=bond0
SLAVE=yes
EOF
[root@www network-scripts]# ifcfg-eth1
cat <<EOF> /etc/sysconfig/network-scripts/ifcfg-eth1
TYPE=Ethernet
NAME=eth1
#UUID=cda4ec94-acaf-4549-82bf-c0080acf21eb
DEVICE=ens224
ONBOOT=yes
MASTER=bond0
SLAVE=yes
EOF
[root@www network-scripts]# ifcfg-bond0
cat <<EOF> /etc/sysconfig/network-scripts/ifcfg-bond1
DEVICE=bond0
BONDING_OPTS=mode=active-backup
TYPE=Bond
BONDING_MASTER=yes
BOOTPROTO=static
NAME=bond0
#UUID=edf218d2-9d71-4c42-bae7-9a4252fc6ecf
ONBOOT=yes
IPADDR=192.168.1.144
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
EOF
4.啟動網卡
nmcli connection up eth0
nmcli connection up eth1
nmcli connection up bond0
5.開機自動加載模塊到內核
vim /etc/modprobe.d/modprobe.conf
echo ‘alias bond1 bonding‘ >> /etc/modprobe.d/modprobe.conf
echo ‘options bond1 miimon=10 mode=1‘ >> /etc/modprobe.d/modprobe.conf
6.service network restart
7.此命令查看綁定情況
cat /proc/net/bonding/bond0
8.開機啟動綁定
/etc/rc.d/rc.local添加如下內容
echo ‘ifenslave bond0 eth0 eth1‘ >> /etc/rc.d/rc.local
9.可以看到調用的是哪幾個物理網卡
cat /proc/net/bonding/bond0
10.測試ifdown eth0/eth1
本文出自 “steven 業精於勤荒於嬉..” 博客,請務必保留此出處http://steven2.blog.51cto.com/855881/1978086
centos7.2網卡綁定