您好,登錄后才能下訂單哦!
這篇文章將為大家詳細講解有關linux中怎么使用nmcli配置主備模式鏈路聚合,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
現在讓我們在CentOS 7中配置網卡綁定,運行ip link命令查看可以使用的網卡
[root@localhost ~]# ip link1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: enp0s3: mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether 08:00:27:7b:d3:32 brd ff:ff:ff:ff:ff:ff 3: enp0s8: mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether 08:00:27:81:d3:be brd ff:ff:ff:ff:ff:ff
在這里使用enp0s3和enp0s8兩個網卡配置 主備模式的鏈路聚合。
[root@localhost ~]# nmcli connection add type team con-name team0 ifname team0 config '{"runner":{"name":"activebackup"}}' Connection 'team0' (4df78635-b9fc-4539-ab02-27db11c656fe) successfully added.
運行nmcli con show查看team0的配置
[root@localhost ~]# nmcli con showNAME UUID TYPE DEVICE team0 4df78635-b9fc-4539-ab02-27db11c656fe team team0 enp0s3 5005942f-a7fd-4e55-b8e7-77928d8da72d ethernet enp0s3 Wired connection 1 45dee64a-53b3-3e2a-b2d4-e377f3e668a2 ethernet enp0s8
在這里使用enp0s3和enp0s8兩個網卡作為team0的slave接口:
[root@localhost ~]# nmcli connection add type team-slave con-name team0-port1 ifname enp0s3 master team0 Connection 'team0-port1' (15183c4a-2053-4b53-ad58-de5a07ae3ae9) successfully added. [root@localhost ~]# nmcli connection add type team-slave con-name team0-port2 ifname enp0s8 master team0Connection 'team0-port2' (a34e20b0-3422-46e5-a947-bb2eaa6c0622) successfully added.
查看端口配置信息:
[root@localhost ~]# nmcli connection show NAME UUID TYPE DEVICE team0 4df78635-b9fc-4539-ab02-27db11c656fe team team0 enp0s3 5005942f-a7fd-4e55-b8e7-77928d8da72d ethernet enp0s3 Wired connection 1 45dee64a-53b3-3e2a-b2d4-e377f3e668a2 ethernet enp0s8 team0-port1 15183c4a-2053-4b53-ad58-de5a07ae3ae9 ethernet -- team0-port2 a34e20b0-3422-46e5-a947-bb2eaa6c0622 ethernet --
給team0分配一個靜態的IP地址并啟動team0配置:
[root@localhost ~]# nmcli connection modify team0 ipv4.method manual ipv4.addresses 192.168.0.200/24 ipv4.gateway 192.168.0.1 ipv4.dns 202.102.128.68[root@localhost ~]# nmcli connection up team0 Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
查看連接配置信息,發現team0-port1沒有綁定在enp0s3這個網卡接口上
[root@localhost ~]# nmcli connection
這是以內ifcfg-team0-port1配置文件和ifcfg-enp0s3兩個配置文件都設置為開機啟動了
所以我們需要關閉enp0s3的開機啟動,在這里我們把enp0s3和Wired connection 1這兩個配置都關掉開機啟動
[root@localhost ~]# nmcli connection modify enp0s3 autoconnect no[root@localhost ~]# nmcli connection modify Wired\ connection\ 1 autoconnect no
然后重啟一下網絡服務,查看鏈接配置:
[root@localhost ~]# systemctl restart network[root@localhost ~]# nmcli connection[root@localhost ~]# ip ad
可以看到team0-port1和team0-port2都綁定在對應的網卡上面了,team0的ip地址顯示的是手動設置的192.168.0.200
查看team0的狀態:
[root@localhost ~]# teamdctl team0 statesetup: runner: activebackup ports: enp0s3 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 0 enp0s8 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 0 runner: active port: enp0s8
現在活動的端口是enp0s8,我們斷開這個端口,看一下主備模式配置是否工作:
[root@localhost ~]# nmcli device disconnect enp0s8 Device 'enp0s8' successfully disconnected. [root@localhost ~]# teamdctl team0 statesetup: runner: activebackup ports: enp0s3 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 0 runner: active port: enp0s3
看到活動接口切換到enp0s3上面了。
關于“linux中怎么使用nmcli配置主備模式鏈路聚合”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。