服务器两张网卡需要做bond,并且bond后网卡需配置不同网段的地址,用于走不同流量,这个时候就可以采用起子接口的方式。
# 第一步:停掉NetworkManager服务
systemctl stop NetworkManager.service systemctl disable NetworkManager.service
# 第二步:备份
cp /etc/sysconfig/network-scripts/ifcfg-enp176s0f0{,.bak} cp /etc/sysconfig/network-scripts/ifcfg-enp176s0f1{,.bak}
# 第三步:将网卡协议改为none并设备未开机自启动,并做双网卡配置
sed -i 's/BOOTPROTO=dhcp/BOOTPROTO=none/' /etc/sysconfig/network-scripts/ifcfg-enp176s0f0 sed -i 's/ONBOOT=no/ONBOOT=yes/' /etc/sysconfig/network-scripts/ifcfg-enp176s0f0 echo "MASTER=bond0" >>/etc/sysconfig/network-scripts/ifcfg-enp176s0f0 echo "SLAVE=yes" >>/etc/sysconfig/network-scripts/ifcfg-enp176s0f0 sed -i 's/BOOTPROTO=dhcp/BOOTPROTO=none/' /etc/sysconfig/network-scripts/ifcfg-enp176s0f1 sed -i 's/ONBOOT=no/ONBOOT=yes/' /etc/sysconfig/network-scripts/ifcfg-enp176s0f1 echo "MASTER=bond0" >>/etc/sysconfig/network-scripts/ifcfg-enp176s0f1 echo "SLAVE=yes" >>/etc/sysconfig/network-scripts/ifcfg-enp176s0f1
# 第四步:配置网卡bond0
echo "DEVICE=bond0 TYPE=Ethernet ONBOOT=yes BOOTPROTO=static" >/etc/sysconfig/network-scripts/ifcfg-bond0
# 第五步:写模块文件,bond模式为mode 0
echo "alias bond0 bonding options bond0 miimon=100 mode=0" >/etc/modprobe.d/bond.conf # 加载模块 modprobe bonding
# 第六步:起子接口
# 起子接口bond0.201 vim /etc/sysconfig/network-scripts/ifcfg-bond0.201 DEVICE=bond0.201 TYPE=Vlan PHYSDEV=bond0 ONBOOT=yes BOOTPROTO=static REORDER_HDR=yes IPADDR=10.10.51.16 GATEWAY=10.10.51.1 NETMASK=255.255.255.0 DNS1=114.114.114.114 DNS2=8.8.8.8 VLAN=yes VLAN_ID=201 # 起子接口bond0.401 vim /etc/sysconfig/network-scripts/ifcfg-bond0.401 DEVICE=bond0.401 TYPE=Vlan PHYSDEV=bond0 ONBOOT=yes BOOTPROTO=static REORDER_HDR=yes IPADDR=111.20.200.90 GATEWAY=111.20.200.89 NETMASK=255.255.255.0 DNS1=114.114.114.114 DNS2=8.8.8.8 VLAN=yes VLAN_ID=401 # 加载模块并重启主机 modprobe 8021q reboot
标签:sysconfig,network,绑定,ifcfg,网卡,etc,scripts,yes,bond From: https://www.cnblogs.com/HByang/p/18143692