办公区域
VLAN 10
IP地址:192.168.1.1/24
Gateway:192.168.1.254
监控区域
VLAN 20
IP地址:192.168.2.1/24
Gateway:192.168.2.254
(1)在所有交换机上创建VLAN 10 和 VLAN 20 ,命令如下。
S1交换机配置命令
The device is running!
<Huawei>system-view //由用户视图进入系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname S1 //将交换机名称更改为S1
[S1]vlan batch 10 20 //连续创建多个vlan
Info: This operation may take a few seconds. Please wait for a moment...done.
[S1]undo info-center enable //关闭系统提示消息
Info: Information center is disabled.
S2交换机配置命令
The device is running!
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname S2
[S2]undo info-center enable
Info: Information center is disabled.
[S2]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
S3交换机配置命令
The device is running!
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]sysname S3
[S3]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
(2)配置交换机端口
①配置交换机S1端口。S1交换机为三层交换机,其端口需要设置为Trunk类型,并允许VLAN 10、20的数据通过。命令如下。
常规操作:
[S1]interface GigabitEthernet 0/0/1
[S1-GigabitEthernet0/0/1]port link-type trunk
[S1-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20
[S1-GigabitEthernet0/0/1]display this
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 10 20
#
return
[S1-GigabitEthernet0/0/1]quit
[S1]interface GigabitEthernet 0/0/2
[S1-GigabitEthernet0/0/2]port link-type trunk
[S1-GigabitEthernet0/0/2]port trunk allow-pass vlan 10 20
[S1-GigabitEthernet0/0/2]display this
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 10 20
#
return
[S1-GigabitEthernet0/0/2]quit
[S1]
便捷操作:
[S1]port-group 1
[S1-port-group-1]group-member GigabitEthernet 0/0/1 to GigabitEthernet 0/0/2
[S1-port-group-1]port link-type trunk
[S1-GigabitEthernet0/0/1]port link-type trunk
[S1-GigabitEthernet0/0/2]port link-type trunk
[S1-port-group-1]port trunk allow-pass vlan 10 20
[S1-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20
[S1-GigabitEthernet0/0/2]port trunk allow-pass vlan 10 20
[S1-port-group-1]display this
#
port-group 1
group-member GigabitEthernet0/0/1
group-member GigabitEthernet0/0/2
#
return
[S1-port-group-1]
②配置交换机S2端口,命令如下。
[S2]interface Ethernet0/0/1
[S2-Ethernet0/0/1]port link-type access
[S2-Ethernet0/0/1]port default vlan 10
[S2-Ethernet0/0/1]display this
#
interface Ethernet0/0/1
port link-type access
port default vlan 10
#
return
[S2-Ethernet0/0/1]quit
[S2]int
[S2]interface GigabitEthernet 0/0/1
[S2-GigabitEthernet0/0/1]port link-type trunk
[S2-GigabitEthernet0/0/1]port trunk allow-pass vlan 10 20
[S2-GigabitEthernet0/0/1]display this
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 10 20
#
return
[S2-GigabitEthernet0/0/1]
③配置交换机S3端口,命令如下。
[S3]interface Ethernet0/0/1
[S3-Ethernet0/0/1]port link-type access
[S3-Ethernet0/0/1]port default vlan 20
[S3-Ethernet0/0/1]display this
#
interface Ethernet0/0/1
port link-type access
port default vlan 20
#
return
[S3-Ethernet0/0/1]quit
[S3]interface GigabitEthernet 0/0/2
[S3-GigabitEthernet0/0/2]port link-type trunk
[S3-GigabitEthernet0/0/2]port trunk allow-pass vlan 10 20
[S3-GigabitEthernet0/0/2]display this
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 10 20
#
return
[S3-GigabitEthernet0/0/2]quit
[S3]
④测试计算机间是否正常通信
在PC1上利用ping命令的测试结果无法通信。
(3)在S1(即三层交换机)上配置VLANIF接口
①配置VLANIF接口IP地址
主要是配置VLANIF接口的IP地址,此地址作为计算机默认网关地址。命令如下。
[S1]interface Vlanif 10 //进入VLAN 10接口视图下
[S1-Vlanif10]ip address 192.168.1.254 24
[S1-Vlanif10]display this
#
interface Vlanif10
ip address 192.168.1.254 255.255.255.0
#
return
[S1-Vlanif10]quit
[S1]interface Vlanif 20 //进入VLAN 20接口视图下
[S1-Vlanif20]ip address 192.168.2.254 24
[S1-Vlanif20]display this
#
interface Vlanif20
ip address 192.168.2.254 255.255.255.0
#
return
[S1-Vlanif20]quit
[S1]
②查看VLANIF信息
[S1]display current-configuration
······
#
interface Vlanif1
#
interface Vlanif10
ip address 192.168.1.254 255.255.255.0
#
interface Vlanif20
ip address 192.168.2.254 255.255.255.0
#
······