Linux bond0 配置方法

Centos7 配置文件

关闭 NetworkManager

bash 复制代码
systemctl stop NetworkManager
systemctl disable NetworkManager

修改网卡配置文件

bond0 配置文件

bash 复制代码
cat /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
ONBOOT=yes
IPADDR=192.168.0.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.254
BONDING_OPTS="mode=4 miimon=100" # 建议将bond0 配置文件放在这个地方方便以后排查问题

ech0 配置文件

bash 复制代码
cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
MASTER=bond0
SLAVE=yes

eth1 配置文件

cat /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1

MASTER=bond0

SLAVE=yes

添加 bond0 配置文件(写在网卡配置文件里面或者单独写一个配置文件,这两个任选其一即可。)

bash 复制代码
vi /etc/modprobe.d/bonding.conf
alias bond0 bonding
options bonding mode=0 miimon=200

加载模块

bash 复制代码
modprobe bonding

确认模块是否加载成功

bash 复制代码
lsmod | grep bonding
bash 复制代码
bonding 100065 0

重启网络服务

bash 复制代码
systemctl restart network

查看网卡状态

bash 复制代码
eth0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP group default qlen 1000
eth1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP group default qlen 1000
bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    inet 192.168.1.10/24 brd 10.5.201.63 scope global noprefixroute bond0

VLAN:在以上基础上增加如下配置文件

bond0 配置文件

bash 复制代码
cat /etc/sysconfig/network-scripts/ifcfg-bond0.101
DEVICE=bond0.101
ONBOOT=yes
IPADDR=192.168.0.100
NETMASK=255.255.255.0
BROADCAST=192.168.0.255
VLAN=yes
ID=101 # 需要添加 VLAN ID号

另外两个网卡配置和上面的一样。

centos8 或者openEuler-22.03

操作步骤

mode 1 模式配置方法

bash 复制代码
nmcli con add type bond ifname bond0 con-name bond0 mode 1 balance-rr
nmcli con add type bond-slave ifname ens33 master bond0
nmcli con add type bond-slave ifname ens36 master bond0
nmcli con modify bond0 ipv4.address 192.168.1.100/24 ipv4.gateway 192.168.1.254 ipv4.method manual ipv6.method ignore
nmcli con up bond0

mode 4 配置方法

bash 复制代码
nmcli con add type bond ifname bond0 con-name bond0 mode 4
nmcli con add type bond-slave ifname ens33 master bond0
nmcli con add type bond-slave ifname ens36 master bond0
nmcli con modify bond0 ipv4.address 192.168.1.100/24 ipv4.gateway 192.168.1.254 ipv4.method manual ipv6.method ignore
nmcli con up bond0
相关推荐
_平凡之路_25 分钟前
解决ubuntu22.04 gnome-terminal 无法启动的问题
linux·运维·python
凯子坚持 c27 分钟前
0基础带你入门Linux之使用
linux·运维·服务器
迈威通信28 分钟前
从EtherCAT到PROFINET,迈威通信带你解锁工业网络!
网络·自动化·信息与通信
hgdlip40 分钟前
电脑ip会因为换了网络改变吗
服务器·网络·tcp/ip·电脑
EterNity_TiMe_1 小时前
【Linux基础IO】深入Linux文件描述符与重定向:解锁高效IO操作的秘密
linux·运维·服务器·学习·性能优化·学习方法
python-码博士1 小时前
Rosetta 一:手把手教你用Linux安装Rosetta(全网最简洁)
linux·运维·服务器
你可以自己看1 小时前
python中函数式编程与高阶函数,装饰器与生成器,异常处理与日志记录以及项目实战
服务器·开发语言·python
神秘的土鸡1 小时前
Linux中Docker容器构建MariaDB数据库教程
linux·运维·服务器·数据库·docker·mariadb
Amd7942 小时前
Nuxt Kit中的 Nitro 处理程序
服务器·插件·处理程序·模块化·nuxt 3·预渲染·nitro
路溪非溪2 小时前
Linux内核启动流程
linux·运维·服务器