zoukankan      html  css  js  c++  java
  • CentOS 7使用nmcli配置双网卡聚合

    进入CentOS 7以后,网络方面变化比较大,例如eth0不见了,ifconfig不见了,其原因是网络服务全部都由NetworkManager管理了,下面记录下今天下午用nmcli配置的网卡聚合,网络上资料比较多,这里仅记录以备忘,更详细的说明可以参考rhel7和centos7使用nmcli命令管理配置网络

    CentOS7使用ip link代替ifconfig命令,使用teamd处理双网卡聚合,使用nmcli命令行配置网络。

    linux聚合有6种模式(抄来的)

    • broadcast 传输来自所有端口的包
    • roundrobin 以轮循的方式传输所有端口的包
    • activebakup 这是一个故障迁移程序,监控链接更改并选择活动的端口进行传输
    • loadbalance 监控流量并使用哈希函数以尝试在选择传输端口的时候达到完美均衡
    • lacp 实施802.3ad 链路聚合协议,可以使用与 loadbalance 运行程序相同的传输端口选择的可能性

    Linux网卡bond的七种模式详解中,介绍了0-6中mode的具体工作模式,在我们这里聚合采用的是lacp模式,主要原因是我们还会使用PXE装机,而PXE只会初始化一块网卡去DHCP申请地址,在这个过程中去修改交换机配置显然是不合适的,只能选择动态聚合。注意lacp模式需要接入交换机支持,下面会分为服务器侧和交换机侧两块配置。

    交换机侧配置

    交换机使用的是CE6851-48S6Q-HI,两台48万兆口交换机(双万兆聚合也是没谁了)。吐槽下华为交换机,比华三的交换机质量差太远了,无论是稳定性还是友好度。我甚至遇到过网卡必须要shutdown/undo shutdown才能UP的情况,就不用说进一个视图需要一分钟这种事情了。可是我们就是不能用H3C的交换机。

    注意Eth-Trunk11口的mode为lacp-dymanic。

    [~HUAWEI-Eth-Trunk11]dis this
    #
    interface Eth-Trunk11
     port link-type trunk
     port trunk pvid vlan 127
     undo port trunk allow-pass vlan 1
     port trunk allow-pass vlan 127
     stp edged-port enable
     mode lacp-dynamic
    #
    return
    [~HUAWEI-10GE1/0/11]dis this
    #
    interface 10GE1/0/11
     eth-trunk 11
     storm suppression unknown-unicast packets 1000
     storm suppression multicast packets 1000
     storm suppression broadcast packets 1000
     device transceiver 10GBASE-FIBER
    #
    return
    [~HUAWEI-10GE2/0/33]dis this
    #
    interface 10GE2/0/33
     eth-trunk 11
     storm suppression unknown-unicast packets 1000
     storm suppression multicast packets 1000
     storm suppression broadcast packets 1000
     device transceiver 10GBASE-FIBER
    #
    return
    

    服务器侧配置

    1、创建bond0口,其mode为lacp。centos7不再使用mode=4这种表示方法了。

    nmcli connection add type team con-name bond0 ifname bond0 config '{"runner":{"name":"lacp"}}'
    

    2、将2个万兆口enp5s0f0、enp5s0f1加到team0里去

    nmcli connection add type team-slave con-name bond0-port1 ifname enp5s0f0 master bond0
    nmcli connection add type team-slave con-name bond0-port2 ifname enp5s0f1 master bond0
    

    3、静态配置team0口地址、网关。 注意不要漏掉网关,否则跨网段就不能用啦。再吐槽一下HW的交换机,ping出去的时候源地址竟然不是根据网络最长匹配的,选择的是其他网段的源地址。

    nmcli connection modify bond0 ipv4.addresses '192.168.127.45/24' ipv4.gateway '192.168.127.254'
    nmcli connection modify bond0 ipv4.method manual
    nmcli connection up bond0
    

    4、验证

    # ip addr show bond0
    25: bond0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
        link/ether 04:27:58:91:58:62 brd ff:ff:ff:ff:ff:ff
        inet 192.168.127.45/24 brd 192.168.127.255 scope global bond0
           valid_lft forever preferred_lft forever
        inet6 fe80::627:58ff:fe91:5862/64 scope link
           valid_lft forever preferred_lft forever
    # ip route
    default via 192.168.127.254 dev bond0
    192.168.127.0/24 dev bond0  proto kernel  scope link  src 192.168.127.45  metric 350
    

    nmcli相比ifconfig特别好的一点是,其配置会下刷到网络的配置文件里去,不需要担心重启以后配置丢失的问题

    转:http://www.datastart.cn/tech/2016/07/19/nmcli.html

  • 相关阅读:
    如何让Surface RT支持网站的flash
    C# 线程同步
    WPF中Visible设为Collapse时,VisualTreeHelper.GetChildrenCount为0
    Set connectionId threw an exception.
    C# 深化基本概念
    wpf如何获取control template里的元素
    DataGrid当列宽超出当前宽度时,没有数据也恒有滚动条
    利用MEF实现插件机制(可根据输入类型来加载特定dll)
    利用正则表达式类解析SQL语句,达到Worklist兼容各个RIS数据库的目的
    Mysql 创建存储过程 更新表
  • 原文地址:https://www.cnblogs.com/fengjian2016/p/6211368.html
Copyright © 2011-2022 走看看