• 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
  • 相关阅读:
    技术管理进阶——如何在面试中考察候选人并增大入职概率
    clion2020 中文版安装
    【树】在二叉树中增加一行 层序遍历
    Docker高级-3.Docker网络与Docker-compose容器编排
    Learn OpenGL 07 摄像机
    基于HMM的拼音输入法
    Vivado 2021.2 Tcl Shell no appropriate Visual C++ redistributable error
    闲置电脑挂机赚钱-Traffmonetizer,支持windows,linux,Android,MacOS多平台
    01. Linux kernel 编译,qemu仿真
    R语言绘图ggplot2 theme elements(ggplot2 主题元素)
  • 原文地址:https://blog.csdn.net/qq_39965541/article/details/138075968