創建vlan
[center_switch]vlan 40
[center_switch-vlan40]quit
給vlan配置IP地址
[center_switch]interface Vlanif 10
[center_switch-Vlanif10] ip address 10.3.0.1 255.255.0.0
將端口加入vlan (少的話可以一個一個加,多了可以分組,將端口組加入vlan)
[center_switch] interface port GigabitEthernet 0/0/24
[center_switch-GigabitEthernet0/0/24]port link-type access
[center_switch-GigabitEthernet0/0/24]port default vlan10
[center_switch-GigabitEthernet0/0/24]quit
[center_switch] interface port GigabitEthernet 0/0/23
[center_switch-GigabitEthernet0/0/23]port link-type access
[center_switch-GigabitEthernet0/0/23]port default vlan10
創建端口組
[center_switch]port-group port1to8forvlan30
將相應的端口加入組中
[center_switch]port-group port1to8forvlan30]group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/8
設置端口方式
[center_switch-port-group-port1to8forvlan30]port link-type access
設置端口組默認vlan(即之前創建好的vlan ID 30)
[center_switch-port-group-port1to8forvlan30]port default vlan 30
trunk口配置方式(trunk口為交換機與交換機之間vlan互相通信的接口,兩台交換機trunk口互連即可)
進入接口
port link-type trunk
port trunk allow-pass vlan all
靜態路由配置
ip route-static 0.0.0.0 0.0.0.0 10.0.0.1
上層還有要路由器的話需要在路由器上配置回指路由(交換機到路由器的靜態路由有了,還需要有路由器到交換機的靜態路由)
vlan下配置dhcp服務
開啟服務
[Huawei]dhcp enable
ip pool vlan10 (池名稱)
network 10.7.0.0 mask 255.255.0.0
gateway-list 10.7.0.1
dns-list 223.5.5.5
lease day 2
quit --
interface Vlanif10
dhcp select global