port-group GROUP-NAME
命令建立組,並經過group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/20
來批量添加組員,之後須要對這些端口操做進入此group就能夠了。三層核心交換機在配置多個不一樣網段互聯時,有如下兩種方式:web
1. 單臂路由方式: 三層核心交換機配置多網絡vlan,與上聯匯聚層設備接口使用trunk透傳,上聯防火牆或路由器建立子接口並對應VLAN做爲網關,vlan間的數據路由在上聯設備完成。緩存
單臂路由方式:網絡
2. 靜態路由方式: 三層核心交換機做爲接入設備,配置多網絡vlan,並建立網關,上聯接口配置靜態IP,交換機和上聯設備添加靜態路由,vlan之間的數據路由在接入交換機上完成。ide
靜態路由方式:測試
路由器:ui
SW1code
SW2server
SW3
默認不用配置,充當二層交換機blog
採用以下的思路配置匯聚層設備做爲網關實現不一樣網段用戶間的通訊: dns
路由器(或者防火牆)的配置很是簡單,只須要在LAN口配置靜態IP,並配置上到網關交換機的靜態路由地址。
# 配置子接口,lan interface Vlanif1 ip address 192.168.1.1 255.255.255.0 # 配置靜態路由,內網的下一跳地址爲匯聚交換機的接口地址 ip route-static 192.168.0.0 255.255.0.0 192.168.1.2
1.建立VLAN。
<HUAWEI> system-view [HUAWEI] sysname SW2 # 修改設備的名稱爲SW2,便於識別 [SW2] vlan batch 2 3 //批量建立VLAN 2和VLAN 3 [SW2] interface gigabitethernet 1/0/23 [SW2-GigabitEthernet1/0/23] port link-type access //將與PC相鏈接口的接口類型設置爲access [SW2-GigabitEthernet1/0/23] port default vlan 2 //將PC1劃分到VLAN 2 [SW2-GigabitEthernet1/0/23] quit [SW2] interface gigabitethernet 1/0/24 [SW2-GigabitEthernet1/0/24] port link-type access [SW2-GigabitEthernet1/0/24] port default vlan 3 //將PC2劃分到VLAN 3 [SW2-GigabitEthernet1/0/24] quit [SW2] interface gigabitethernet 1/0/1 [SW2-GigabitEthernet1/0/1] port link-type trunk //將與匯聚交換機相鏈接口的接口類型設置爲trunk [SW2-GigabitEthernet1/0/1] port trunk allow-pass vlan 2 3 //透傳VLAN 2和VLAN 3到匯聚交換機SW1 [SW2-GigabitEthernet1/0/1] quit
1.建立vlan
<HUAWEI> system-view [HUAWEI] sysname SW1 //修改設備的名稱爲SW1 [SW1] vlan batch 2 to 4 //批量建立VLAN 2到VLAN 4
2.將鏈接PC的接口加入相應VLAN。
[SW1] interface gigabitethernet 1/0/2 [SW1-GigabitEthernet1/0/2] port link-type trunk //將與SW1相鏈接口的接口類型設置爲trunk [SW1-GigabitEthernet1/0/2] port trunk allow-pass vlan 2 3 //透傳VLAN 2和VLAN 3 [SW1-GigabitEthernet1/0/2] quit [SW1] interface gigabitethernet 1/0/3 [SW1-GigabitEthernet1/0/3] port link-type access //將與PC3相鏈接口的接口類型設置爲access [SW1-GigabitEthernet1/0/3] port default vlan 4 //將PC3劃分到VLAN 4 [SW1-GigabitEthernet1/0/3] quit
3.配置VLANIF接口,做爲用戶PC的網關。
[SW1] interface vlanif 2 //建立VLANIF2接口 [SW1-Vlanif2] ip address 192.168.2.1 24 //配置IP地址,此IP地址是PC1的網關地址 [SW1-Vlanif2] quit [SW1] interface vlanif 3 //建立VLANIF3接口 [SW1-Vlanif3] ip address 192.168.3.1 24 //配置IP地址,此IP地址是PC2的網關地址 [SW1-Vlanif3] quit [SW1] interface vlanif 4 //建立VLANIF4接口 [SW1-Vlanif4] ip address 192.168.4.1 24 //配置IP地址,此IP地址是PC3的網關地址 [SW1-Vlanif4] quit
[SW1] interface Vlanif1 [SW1] ip address 192.168.1.1 255.255.255.0 [SW1] interface gigabitethernet 1/0/1 [SW1-GigabitEthernet1/0/1] port link-type access //將與路由器相鏈接口的接口類型設置爲access,與 路由器經過Untagged方式通訊 ,默認爲VLAN1 [SW1-GigabitEthernet1/0/1] quit [SW1] ip route-static 0.0.0.0 0.0.0.0 192.168.1.1 // 配置一條到路由器的缺省路由
dis cu
PC一、PC二、PC3之間能夠相互訪問,同時PC均可以和路由器進行通訊。
路由器
SW1(可按照以下配置,也能夠所有配置爲vlan1或vlan5)
SW2
SW3
採用以下的思路配置接入層設備做爲網關實現不一樣網段用戶間的通訊:
路由器(或者防火牆)的配置很是簡單,只須要在LAN口配置靜態IP,並配置上到網關交換機的靜態路由地址。
# 配置子接口,lan interface Vlanif1 ip address 192.168.1.1 255.255.255.0 # 配置靜態路由 ip route-static 192.168.0.0 255.255.0.0 192.168.1.2
<HUAWEI> system-view [HUAWEI] sysname SW2 //修改設備的名稱爲SW2,便於識別 [SW2] vlan batch 2 to 3 //批量建立VLAN 2和VLAN
[SW2] interface gigabitethernet 1/0/23 [SW2-GigabitEthernet1/0/23] port link-type access //將與PC相鏈接口的接口類型設置爲access [SW2-GigabitEthernet1/0/23] port default vlan 2 //將PC1劃分到VLAN 2 [SW2-GigabitEthernet1/0/23] quit [SW2] interface gigabitethernet 1/0/24 [SW2-GigabitEthernet1/0/24] port link-type access [SW2-GigabitEthernet1/0/24] port default vlan 3 //將PC2劃分到VLAN 3 [SW2-GigabitEthernet1/0/24] quit
[SW2] interface vlanif 2 //建立VLANIF2接口 [SW2-Vlanif2] ip address 192.168.2.1 24 //配置IP地址,此IP地址是PC1的網關地址 [SW2-Vlanif2] quit [SW2] interface vlanif 3 //建立VLANIF3接口 [SW2-Vlanif3] ip address 192.168.3.1 24 //配置IP地址,此IP地址是PC2的網關地址 [SW2-Vlanif3] quit
4.配置SW2和SW1互連
[SW2] vlan batch 5 //建立VLAN 5 [SW2] interface gigabitethernet 1/0/1 [SW2-GigabitEthernet1/0/1] port link-type access [SW2-GigabitEthernet1/0/1] port default vlan 5 //SW2和SW1以Untagged方式通訊 [SW2-GigabitEthernet1/0/1] quit [SW2] interface vlanif 5 //建立VLANIF5接口 [SW2-Vlanif5] ip address 192.168.5.2 24 //配置IP地址,此IP地址是SW2與SW1互鏈接口的IP地址 [SW2-Vlanif5] quit [SW2] ip route-static 0.0.0.0 0.0.0.0 192.168.5.1 //配置缺省路由,爲PC用戶找到訪問路由器的出口。 缺省路由的下一跳是SW1相鏈接口的IP地址
<HUAWEI> system-view [HUAWEI] sysname SW3 //修改設備的名稱爲SW3 [SW3] vlan batch 4 //批量建立VLAN 4
[SW3] interface gigabitethernet 1/0/2 [SW3-GigabitEthernet1/0/2] port link-type access //將與PC相鏈接口的接口類型設置爲access [SW3-GigabitEthernet1/0/2] port default vlan 4 //將PC3劃分到VLAN 4 [SW3-GigabitEthernet1/0/2] quit
[SW3] vlan batch 5 //建立VLAN 5 [SW3] interface gigabitethernet 1/0/1 [SW3-GigabitEthernet1/0/1] port link-type access [SW3-GigabitEthernet1/0/1] port default vlan 5 //SW3和SW1以Untagged方式通訊 [SW3-GigabitEthernet1/0/1] quit [SW3] interface vlanif 5 //建立VLANIF5接口 [SW3-Vlanif5] ip address 192.168.5.3 24 //配置IP地址,此IP地址是SW3與SW1互鏈接口的IP地址 [SW3-Vlanif5] quit [SW3] ip route-static 0.0.0.0 0.0.0.0 192.168.5.1 //配置缺省路由,爲PC用戶指定訪問路由器的出口。 缺省路由的下一跳是SW1相鏈接口的IP地址
<HUAWEI> system-view [HUAWEI] sysname SW1 //修改設備的名稱爲SW1 [SW1] vlan batch 5 //批量建立VLAN 5
[SW1] interface gigabitethernet 1/0/1 [SW1-GigabitEthernet1/0/1] port link-type access //將與路由器相鏈接口的接口類型設置爲access [SW1-GigabitEthernet1/0/1] port default vlan 1 [SW1-GigabitEthernet1/0/1] quit [SW1] interface gigabitethernet 1/0/2 [SW1-GigabitEthernet1/0/2] port link-type access //將與SW2相鏈接口的接口類型設置爲access [SW1-GigabitEthernet1/0/2] port default vlan 5 [SW1-GigabitEthernet1/0/2] quit [SW1] interface gigabitethernet 1/0/3 [SW1-GigabitEthernet1/0/3] port link-type access //將與SW3相鏈接口的接口類型設置爲access [SW1-GigabitEthernet1/0/3] port default vlan 5 [SW1-GigabitEthernet1/0/3] quit
3.配置VLANIF接口,實現和路由器的互連
[SW1] interface vlanif 5 //建立VLANIF5接口 [SW1-Vlanif5] ip address 192.168.5.1 24 //配置IP地址,此IP地址是與接入交換機對接的IP地址 [SW1-Vlanif5] quit [SW1] interface vlanif 1 [SW1-Vlanif1] ip address 192.168.1.2 24 //配置IP地址,此IP地址是與路由器對接的IP地址 [SW1-Vlanif1] quit
[SW1] ip route-static 192.168.2.0 255.255.255.0 192.168.5.2 //目的IP是192.168.2.0/24網段的,下 一跳是192.168.5.2,該IP地址對應SW2相鏈接口VLANIF的IP地址 [SW1] ip route-static 192.168.3.0 255.255.255.0 192.168.5.2 //目的IP是192.168.3.0/24網段的,下 一跳是192.168.5.2,該IP地址對應SW2相鏈接口VLANIF的IP地址 [SW1] ip route-static 192.168.4.0 255.255.255.0 192.168.5.3 //目的IP是192.168.4.0/24網段的,下 一跳是192.168.5.3,該IP地址對應SW3相鏈接口VLANIF的IP地址
[SW1] ip route-static 0.0.0.0 0.0.0.0 192.168.1.1 //假設路由器與SW1相鏈接口的IP地址是 192.168.1.1
PC一、PC二、PC3之間能夠相互訪問,同時PC均可以和路由器進行通訊。
# 全局開啓dhcp dhcp enable dhcp server database enable # 在子接口上配置dhcp interface Vlanif20 ip address 192.168.20.254 255.255.255.0 dhcp select interface # 設置保留分配的IP dhcp server excluded-ip-address 192.168.20.201 192.168.20.253 # 設置DHCP緩存時間 dhcp server lease day 0 hour 8 minute 0 # 設置DNS dhcp server dns-list 8.8.8.8 114.114.114.114
interface MEth 0/0/1 ip address 192.168.0.1 24