• Linux bond0 配置方法


    Centos7 配置文件

    关闭 NetworkManager

    systemctl stop NetworkManager
    systemctl disable NetworkManager
    
    • 1
    • 2

    修改网卡配置文件

    bond0 配置文件

    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 配置文件放在这个地方方便以后排查问题
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    ech0 配置文件

    cat /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=eth0
    MASTER=bond0
    SLAVE=yes
    
    • 1
    • 2
    • 3
    • 4

    eth1 配置文件
    cat /etc/sysconfig/network-scripts/ifcfg-eth1
    DEVICE=eth1
    MASTER=bond0
    SLAVE=yes

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

    vi /etc/modprobe.d/bonding.conf
    alias bond0 bonding
    options bonding mode=0 miimon=200
    
    • 1
    • 2
    • 3

    加载模块

    modprobe bonding
    
    • 1

    确认模块是否加载成功

    lsmod | grep bonding
    
    • 1
    bonding 100065 0
    
    • 1

    重启网络服务

    systemctl restart network
    
    • 1

    查看网卡状态

    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
    
    • 1
    • 2
    • 3
    • 4

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

    bond0 配置文件

    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号
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

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

    centos8 或者openEuler-22.03

    操作步骤
    mode 1 模式配置方法

    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
    
    • 1
    • 2
    • 3
    • 4
    • 5

    mode 4 配置方法

    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
    
    • 1
    • 2
    • 3
    • 4
    • 5
  • 相关阅读:
    【Docker】学习笔记
    Git:Git的一些基本操作
    (数据结构)线性表的定义和基本操作
    【CKA考试笔记】七、密码管理
    佛山复星禅诚医院黄汉森:云边协同,打造线上线下一体化智慧医疗
    初识Classic AUTOSAR开发工具链
    面试官:设计模式之简单工厂模式
    每天 20 题吃透这份将近 500 页的“Java 工程师八股文”,成功入职阿里
    K8S环境搭建
    react源码中的hooks
  • 原文地址:https://blog.csdn.net/qq_39965541/article/details/138075968