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
相关推荐
March.s6 分钟前
深入理解 Linux 系统启动原理
linux·运维·服务器
zbyyd34 分钟前
Linux 基础与 Shell 命令
linux·运维·arm开发
起名真的太难了40 分钟前
Linux系统运维与远程管理核心命令速查指南
linux·运维·服务器
tg_xianheyun1 小时前
阿里云国际账号注册代充值怎么选服务商?
服务器·阿里云·云计算·全球访问优化
xiaoye-duck1 小时前
《Linux网络编程》吃透 Linux 网络传输全流程:完整梳理局域网通信、封装解包与跨网络传输原理
linux·网络
深念Y1 小时前
订阅管理及节点过滤实践(技术笔记)
linux·网络·arm·优化·日志·工具·soc
IT小盘1 小时前
17-AI应用防止越权访问知识库
服务器·网络·windows
酷可达拉斯1 小时前
自动化运维-Ansible Role详解
linux·运维·服务器·自动化·ansible
为思念酝酿的痛1 小时前
Socket编程--TCP
服务器·网络·tcp/ip
牢姐与蒯1 小时前
Linux首战之进度条
linux·运维·服务器