查看硬件状态
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
原文地址:http://steven2.blog.51cto.com/855881/1978086