鏈路聚合與vlan-trunk功能設置:


# 交換機鏈路聚合配置:
terface Bridge-Aggregation 1  #創建聚合口1
link-aggregation mode dynamic
port link-type trunk #聚合口設置為trunk模式
port link-type trunk #聚合口設置為trunk模式

# 進入接口,綁定聚合口
interface Ten-GigabitEthernet 1/0/17
port link-type trunk
port trunk permit vlan all
port link-aggregation group 1#綁定剛剛創建的聚合口1

interface Ten-GigabitEthernet 1/0/18
port link-type trunk
port trunk permit vlan all
port link-aggregation group 1#綁定剛剛創建的聚合口1

# 客戶都與服務端口
interface Ten-GigabitEthernet 1/0/15
port link-type trunk
port trunk permit vlan 55
dis cur interface Ten-GigabitEthernet 1/0/15
qu
int Bridge-Aggregation 1
link-aggregation mode dynamic
qu
 
[H3C]display history-command
dis link-aggr verbose

display interface Bridge-Aggregation 1  #命令查看聚合口信息
display interface brief   #查看接口狀態


#Linux創建鏈路聚合:
什么是網卡聚合
網卡的鏈路聚合一般常用的有"bond"和"team"兩種模式,"bond"模式最多可以添加兩塊網卡,"team"模式最多可以添加八塊網卡.
bond聚合
Red Hat Enterprise Linux 允許管理員使用 bonding 內核模塊和稱為通道綁定接口的特殊網絡接口將多個網絡接口綁定到一個通道
根據選擇的綁定模式 , 通道綁定使兩個或更多個網絡接口作為一個網絡接口 , 從而增加帶寬和 / 提供冗余性
利用 nmcli 命令管理 bond
yum install NetworkManager-tui
systemctl start NetworkManager
nmcli connection show


(2)添加bond聚合的接口
nmcli connection add con-name bond1 ifname bond1 type bond mode active-backup ip4 2.2.2.2/24
添加兩塊網卡 
nmcli connection add con-name team1-2 ifname eth2 type bond-slave master bond1
nmcli connection add con-name team1-3 ifname eth3 type bond-slave master bond1
nmcli connection show  #看聚和網卡是否添加成功

采用聚合方式當網卡壞了客戶不會有任何感覺

(2)添加team聚合口
鏈路聚合的優勢:
team 聚合連接(也稱為鏈路聚合):
  由多塊網卡(team-slave)一起組建而成的虛擬網卡,即組隊。

作用1:輪詢式的流量負載均衡
作用2:熱備份連接冗余

實現鏈路聚合的條件:
  2塊或2塊以上的物理網卡
  
步驟如下:
1.創建虛擬網卡team1  【為聚合連接提供配置(類型,連接名,運行器,IP地址)】
# nmcli connection add type team con-name team1 ifname team1 autoconnect yes config '{"runner": {"name": "activebackup"}}'
解釋 numcli connection 添加  類型 team 配置文件名稱 team1 ifconfig顯示的名字為team1 每次開機自動啟動配置 熱備份方式


2.添加成員【為成員網卡提供配置(類型,連接名,主連接)】
# nmcli connection add type team-slave con-name team1-1 ifname eth2 master team1
# nmcli connection add type team-slave con-name team1-2 ifname eth3 master team1

3.配置IP地址
# nmcli connection modify team1 ipv4.method manual ipv4.addresses 2.2.2.2/24 connection.autoconnect yes

4.激活 【分別激活聚合連接,成語連接】
# nmcli connection up team1
# nmcli connection up team1-1
# nmcli connection up team1-2

5.驗證查看【檢查聚合連接狀態】
# teamdctl team1 state
# ifconfig eth2 down
# teamdctl team1 state

cat /proc/net/bonding/bond1


# 如果敲錯誤: nmcli connection delete team1
# 如果敲錯誤: nmcli connection delete team1-1
# 如果激活失敗
# nmcli connection delete team1
# nmcli connection delete team1-1
# nmcli connection delete team1-2


示例:
team工作模式:
   roundrobin模式也稱為輪詢模式,它基於每一個包服務器發出的數據包,就會在兩個物理網卡上進行輪詢,
即第一個數據包走一張網卡,第二個數據包走第二張網卡,依次輪詢,相當於 bond 中的 mode 0。在交換機上需要配置鏈路聚合。

  注意:
        (1)roundrobin具有容錯性,當一張網卡down掉,數據包依然發送成功。
        (2)在使用roundrobin模式必須要在交換機上做以太通道,不然會出現網絡無法連通。

  activebackup模式  主備模式, 相當於 bond 中的 mode 1.    在交換機上不需要做鏈路聚合配置。

二、基礎環境
  系統:centos 7  全新安裝的系統。

三、配置

  1、查看物理網卡信息:#nmcli dev sh
    可以看em2 沒有連接

2、查看網卡鏈接信息。#nmcli con sh

3、創建team接口,根據自己的業務需求,配置工作模式。
  #nmcli con add type team con-name team0 ifname team0 config '{"runner":{"name": "roundrobin"}}'    (模式:根據業務需求進行配置工作模式)

4、給接口配置IP地址
  #nmcli con modify team0 ipv4.address '192.168.1.10/24' ipv4.gateway '192.168.1.1' ipv4.dns '114.114.114.114'

5、設置接口模式為手動模式,取消DHCP
  #nmcli con modify team0 ipv4.method manual

6、將物理網卡添加到team中
  #nmcli con add type team-slave ifname em1 master team0
    #nmcli con add type team-slave ifname em2 master team0

7、重啟網卡  #service network restart

8、查看team0 狀態   #teamdctl team0 state

注:如果喜歡使用圖形化界面進行配置的可以使用命令

   
四、后期維護操作
  1、啟用team0 接口中的網卡:
    #nmcli connection up team-slave-em1
    #nmcli connection up team-slave-em2
  2、
    # teamnl team0 ports
    現實網卡em2 down,原因沒有接線。
  3、   
     # teamnl team0 options
  4、刪除網卡連接信息  #nmcli con del  team-slave-em2
   5、刪除team0     #nmcli dev del team0

注意:

設備上的聚合口與交換機上的聚合口需要一致,設置上鏈路聚合只有兩個成員口(eth2/eth3),故交換機上也是兩個(17/18),
另外,創建鏈路聚合口之后,不能在成員口中添加ip地址,否則會不通;

拓撲模式如下:

配置網卡為vlan trunk:https://www.shuzhiduo.com/A/Vx5Mb19YdN/

1,安裝vlan(vconfig)和加載8021q 模塊
# modprobe 8021q
# lsmod | grep 8021q

yum -y install epel-release
yum -y install vconfig -y
yum install net-tools -y

ls /porc/net/vlan

2,在ens5,ens6接口上配置VLAN
vconfig add ens5 55
vconfig add ens6 66

ls /proc/net/vlan

# ifconfig ens5.55 2.2.2.2 netmask 255.255.255.0 broadcast 2.2.2.255 up
# ifconfig ens6.66 3.3.3.3 netmask 255.255.255.0 broadcast 3.3.3.255 up

# 刪除vlan
# ifconfig ens6.66 down
# vconfig rem ens6.66

# 通過ip
# ip link add link ens6 name ens6.55 type vlan id 55
# ip link
# ip -d link show ens6.55
 
# ip addr add 2.2.2.2/24 brd 2.2.2.255 dev ens6.55
# ip link set dev ens6.55 up

# 刪除
# ip link set dev ens6.55 down
# ip link delete ens6.55


示例:
vconfig命令是VLAN配置命令。
1,安裝vlan(vconfig)和加載8021q模塊
[root@test0001~]#yum install vconfig
[root@test0001~]#modprobe 8021q
[root@test0001~]#lsmod |grep -i 8021q
2,在eth0接口上配置兩個VLAN
[root@test0001~]#vconfig add eth0 100
[root@test0001~]#vconfig add eth0 200
3,設置VLAN的REORDER_HDR參數,默認就行了
[root@test0001~]#vconfig set_flag eth0.100 1 1
[root@test0001~]#vconfig set_flag eth0.200 1 1
4,配置網絡信息
[root@test0001~]#ifconfig eth0 0.0.0.0
[root@test0001~]#ifconfig eth0.100 172.16.1.8 netmask 255.255.255.0 up
[root@test0001~]#ifconfig eth0.200 172.16.2.8 netmask 255.255.255.0 up
5,刪除VLAN命令
[root@test0001~]#vconfig rem eth0.100
[root@test0001~]#vconfig rem eth0.200

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM