Centos 7配置网卡绑定bond0

原创作者:运维工程师 谢晋

网卡绑定bond0的实现

查看系统版本

# cat /etc/redhat-release 
CentOS Linux release 7.9.2009 (Core)

VMware虚拟机添加一块新网卡
Centos 7配置网卡绑定bond0_第1张图片
可以看到新加了一块网卡(DHCP自动获取到了地址)
Centos 7配置网卡绑定bond0_第2张图片
配置物理网卡

# cat ifcfg-eth0
NAME=eth0
DEVICE=eth0
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
ONBOOT=yes
# cat ifcfg-eth1
NAME=eth1
DEVICE=eth1
BOOTPROTO=none# cat ifcfg-bond0 
NAME=bond0
TYPE=bond
DEVICE=bond0
BOOTPROTO=none
IPADDR=192.168.20.132
PREFIX=24
GATEWAY=192.168.20.1
DNS1=114.114.114.114
BONDING_OPTS="mode=1 miimon=100 fail_over_mac=1"
MASTER=bond0
SLAVE=yes
ONBOOT=yes

加载bond0

# systemctl restart network.service 
# modprobe bonding

查看bond0状态

# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: fault-tolerance (active-backup) (fail_over_mac active)
Primary Slave: None
Currently Active Slave: eth0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:50:56:9c:6f:82
Slave queue ID: 0

Slave Interface: eth1
MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:50:56:9c:a4:9a
Slave queue ID: 0

查看IP

# ifconfig
bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500
        inet 192.168.20.132  netmask 255.255.255.0  broadcast 192.168.20.255
        inet6 fe80::250:56ff:fe9c:6f82  prefixlen 64  scopeid 0x20<link>
        ether 00:50:56:9c:6f:82  txqueuelen 1000  (Ethernet)
        RX packets 121  bytes 10200 (9.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 76  bytes 10536 (10.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

测试
关闭一张网卡IP仍然能通信
Centos 7配置网卡绑定bond0_第3张图片
Centos 7配置网卡绑定bond0_第4张图片

你可能感兴趣的:(Linux运维,网络&安全,运维,linux)