当前位置: > CentOS > CentOS入门 >

CentOS 7使用nmcli配置网卡聚合链路

时间:2015-03-24 12:25来源:linux.it.net.cn 作者:IT
CentOS7系列对多网卡的配置发生很大的改变,以下以基于RECL-7.0系列对actviebackup属性的配置笔记。

[root@server0 ~]# nmcli con show      //蓝色粗体的网卡是本例配置的网卡
NAME                   UUID                                  TYPE            DEVICE
Ethernet connection 2  8afe67cc-20ef-4985-86c3-b8d3c9371fc9  802-3-ethernet  ens34
Ethernet connection 3  0cf045a5-012c-46bd-9367-1139666871b5  802-3-ethernet  ens35

eth0                   ff18a078-5b66-4bb8-8bba-fafd426b9d39  802-3-ethernet  ens32



# 创建一个名为team0并且属性为team的链路接口

[root@server0 ~]# nmcli con add type team con-name team0 ifname team0 config '{"runner": {"name":"activebackup"}}'


# 为team0配置ip地址与网关
[root@server0 ~]# nmcli connection modify team0 ipv4.addresses "192.168.25.211/24 192.168.25.250"
 
# 为team0配置DNS
[root@server0 ~]# nmcli connection modify team0 ipv4.dns "192.168.10.86 192.168.10.87" 

# 设置team0的属性为 manual
[root@server0 ~]# nmcli connection modify team0 ipv4.method manual 


# 将ent34网卡口 加到team0接口
[root@server0 ~]# nmcli connection add type team-slave conn-name team-port1 ifname ens34 master team0


# 将ent35网卡口 加到team0接口
[root@server0 ~]# nmcli connection add type team-slave conn-name team-port2 ifname ens35 master team0

# 启用接口中的网卡
[root@server0 ~]# nmcli connection up team-port1;nmcli connection up team-port2
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/25)
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/26)



[root@server0 ~]# teamdctl team0 state view
setup:
  runner: activebackup
ports:
  ens34
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
  ens35
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
runner:
  active port: ens34        //当前team0的主接口


[root@server0 ~]# ifconfig team0
team0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.25.211  netmask 255.255.255.0  broadcast 192.168.25.255
        inet6 fe80::20c:29ff:fea7:34b  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:a7:03:4b  txqueuelen 0  (Ethernet)
        RX packets 55  bytes 4477 (4.3 KiB)
        RX errors 0  dropped 70  overruns 0  frame 0
        TX packets 61  bytes 8297 (8.1 KiB)
        TX errors 0  dropped 9 overruns 0  carrier 0  collisions 0


[root@server0 ~]# teamnl team0 ports
 4: ens35: up 1000Mbit FD
 3: ens34: up 1000Mbit FD


[root@server0 ~]# teamnl team0 options
 queue_id (port:ens35) 0
 priority (port:ens35) 0
 user_linkup_enabled (port:ens35) false
 user_linkup (port:ens35) true
 enabled (port:ens35) true
 queue_id (port:ens34) 0
 priority (port:ens34) 0
 user_linkup_enabled (port:ens34) false
 user_linkup (port:ens34) true
 enabled (port:ens34) true
 mcast_rejoin_interval 0
 mcast_rejoin_count 0
 notify_peers_interval 0
 notify_peers_count 0
 mode roundrobin


测试
开启一个ping 窗口,并禁用team0中的其中的一块网卡
=============================================
[root@server0 ~]# nmcli device disconnect ens34

Tips:原则上ping 数据1个包都不会掉 (责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容