创建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