bond绑定两张物理网卡为一张逻辑网卡

问题:cnetos7同时接入两个独立网络,但两个网络的IP网段相同时只能路由到一个网络

解决方法:使用bond绑定两张物理网卡为一张逻辑网卡

1.新建文件bond.conf,内容如下

alias bond0 bonding
options bond0 miimon=100 mode=3

2.新建文件ifcfg-bond0,内容如下

DEVICE=bond0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.138
NETMASK=255.255.255.0
GATEWAY=192.168.0.1

3.修改要绑定的网卡配置文件,例如bond enp1s0和enp2s0两张网卡,配置文件ifcfg-enp1s0和ifcfg-enp2s0修改如下

ifcfg-enp1s0

DEVICE=enp1s0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
GATEWAY=none   

ifcfg-enp2s0

DEVICE=enp2s0
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
GATEWAY=none   

4.新建文件install.sh,内容如下

#!/bin/bash

#configure and install bond

echo "starting>>>>>"
cp /root/bond/bond.conf /etc/modprobe.d/ -f

mv /etc/sysconfig/network-scripts/ifcfg-enp1s0 /etc/sysconfig/network-scripts/ifcfg-enp1s0-backup -f
mv /etc/sysconfig/network-scripts/ifcfg-enp2s0 /etc/sysconfig/network-scripts/ifcfg-enp2s0-backup -f
cp /root/bond/ifcfg-bond0 /etc/sysconfig/network-scripts/ -f
cp /root/bond/ifcfg-enp1s0 /etc/sysconfig/network-scripts/ -f
cp /root/bond/ifcfg-enp2s0 /etc/sysconfig/network-scripts/ -f

init 6

echo "success<<<<<<"

5.运行install.sh脚本安装配置

原文地址:https://www.cnblogs.com/dmj666/p/8032177.html