zoukankan      html  css  js  c++  java
  • linux6.5 网卡绑定

      

    Linux网口绑定

    通过网口绑定(bond)技术,可以很容易实现网口冗余,负载均衡,从而达到高可用高可靠的目的。前提约定:

    2个物理网口分别是:eth0,eth1

    绑定后的虚拟口是:bond0

    服务器IP是:192.168.0.100

    第一步,配置设定文件:

    /etc/sysconfig/network-scripts/ifcfg-bond0

    DEVICE=bond0

    BOOTPROTO=none

    ONBOOT=yes

    IPADDR=192.168.0.100

    NETMASK=255.255.255.0

    NETWORK=192.168.0.0

    BROADCAST=192.168.0.255

    #BROADCAST广播地址

    /etc/sysconfig/network-scripts/ifcfg-eth0

    DEVICE=eth0

    BOOTPROTO=none

    MASTER=bond0

    SLAVE=yes

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

    DEVICE=eth1

    BOOTPROTO=none

    MASTER=bond0

    SLAVE=yes

    第二步,修改modprobe相关设定文件,并加载bonding模块:

    1.在这里,我们直接创建一个加载bonding的专属设定文件/etc/modprobe.d/bonding.conf

    [root@test ~]# vi /etc/modprobe.d/bonding.conf

    #追加

    alias bond0 bonding

    options bonding mode=0 miimon=200

    2.加载模块(重启系统后就不用手动再加载了)

    [root@test ~]# modprobe bonding

    3.确认模块是否加载成功:

    [root@test ~]# lsmod | grep bonding

    bonding 100065 0

    第三步,重启一下网络,然后确认一下状况:

    [root@test ~]# /etc/init.d/network restart

    [root@test ~]# cat /proc/net/bonding/bond0

    Ethernet Channel Bonding Driver: v3.5.0 (November 4, 2008)

    Bonding Mode: fault-tolerance (active-backup)

    Primary Slave: None

    Currently Active Slave: eth0

    ……

     [root@test ~]# ifconfig | grep HWaddr

    bond0 Link encap:Ethernet HWaddr 00:16:36:1B:BB:74

    eth0 Link encap:Ethernet HWaddr 00:16:36:1B:BB:74

    eth1 Link encap:Ethernet HWaddr 00:16:36:1B:BB:74

    从上面的确认信息中,我们可以看到3个重要信息:

    1.现在的bonding模式是active-backup

    2.现在Active状态的网口是eth0

    3.bond0,eth1的物理地址和处于active状态下的eth0的物理地址相同,这样是为了避免上位交换机发生混乱。

    任意拔掉一根网线,然后再访问你的服务器,看网络是否还是通的。

    第四步,系统启动自动绑定、增加默认网关:

    [root@test ~]# vi /etc/rc.d/rc.local

    #追加

    ifenslave bond0 eth0 eth1

    route add default gw 192.168.0.1

    #如可上网就不用增加路由,0.1地址按环境修改.
    ---------------------
    作者:无影V随风
    来源:CSDN
    原文:https://blog.csdn.net/wmj2004/article/details/53216005

  • 相关阅读:
    Fidder4 顶部提示 “The system proxy was changed,click to reenable fiddler capture”。
    redis 哨兵 sentinel master slave 连接建立过程
    虚拟点赞浏览功能的大数据量测试
    python基础练习题(题目 字母识词)
    python基础练习题(题目 回文数)
    python基础练习题(题目 递归求等差数列)
    python基础练习题(题目 递归输出)
    python基础练习题(题目 递归求阶乘)
    python基础练习题(题目 阶乘求和)
    python基础练习题(题目 斐波那契数列II)
  • 原文地址:https://www.cnblogs.com/cnqfz/p/10278291.html
Copyright © 2011-2022 走看看