美文网首页
网卡绑定

网卡绑定

作者: 心疼你萌萌哒 | 来源:发表于2018-07-02 20:11 被阅读0次

    [root@localhost ~]# modprobe --first-time bonding
    [root@localhost ~]# lsmod|grep bonding
    bonding 145728 0

    cat > /etc/sysconfig/network-scripts/ifcfg-bond0 <<eof
    DEVICE=bond0
    BOOTPROTO=none
    ONBOOT=yes
    IPADDR=192.168.44.13
    NETMASK=255.255.255.0
    GATEWAY=192.168.44.2
    DNS1=8.8.8.8
    eof

    cat > /etc/sysconfig/network-scripts/ifcfg-ens33 <<eof
    DEVICE=ens33
    BOOTPROTO=none
    MASTER=bond0
    SLAVE=yes
    eof

    cat > /etc/sysconfig/network-scripts/ifcfg-ens37 <<eof
    DEVICE=ens37
    BOOTPROTO=none
    MASTER=bond0
    SLAVE=yes
    eof

    cat > /etc/modprobe.d/bonding.conf <<eof
    alias bond0 binding
    options bond0 miimon=100 mode=0
    eof
    systemctl restart network
    cat /proc/net/bonding/bond0

    测试,宕掉当前主接口,看是否切换
    ifdown ens33
    cat /proc/net/bonding/bond0
    ifup ens33

    !/bin/bash

    创建一个名为bond0的链路接口

    IP=192.168.44.44
    GATE=192.168.44.2
    ETH1=ens33
    ETH2=ens37
    modprobe bonding
    cat <<EOF> /etc/sysconfig/network-scripts/ifcfg-bond0
    DEVICE=bond0
    TYPE=Bond
    NAME=bond0
    BONDING_MASTER=yes
    BOOTPROTO=static
    USERCTL=no
    ONBOOT=yes
    IPADDR=IP PREFIX=24 GATEWAY=GATE
    BONDING_OPTS="mode=1 miimon=100"
    EOF
    cat <<EOF> /etc/sysconfig/network-scripts/ifcfg-ETH1 TYPE=Ethernet BOOTPROTO=none DEVICE=ETH1
    ONBOOT=yes
    MASTER=bond0
    SLAVE=yes
    EOF
    cat <<EOF> /etc/sysconfig/network-scripts/ifcfg-ETH2 TYPE=Ethernet BOOTPROTO=none DEVICE=ETH2
    ONBOOT=yes
    MASTER=bond0
    SLAVE=yes
    EOF
    systemctl restart network
    ping $GATE -c 1
    reboot

    相关文章

      网友评论

          本文标题:网卡绑定

          本文链接:https://www.haomeiwen.com/subject/rmzluftx.html