1. 组网需求 • Host A 和Host C 属于部门A,但是通过不同的设备接入公司网络;Host B 和Host D 属于部门B,也通过不同的设备接入公司网络。 为了通信的安全性,也为了避免广播报文泛滥,公司网络中使用 VLAN 技术来隔离部门间的 二层流量。其中部门A 使用VLAN 100,部门B 使用VLAN 200。 现要求不管是否使用相同的设备接入公司网络,同一 VLAN 内的主机能够互通,即Host A 和Host C 能够互通,Host B 和Host D 能够互通。

  2. 配置步骤

(1) 配置 Device A 创建VLAN 100,并将GigabitEthernet1/0/1 加入VLAN 100。 <DeviceA> system-view [DeviceA] vlan 100 [DeviceA-vlan100] port gigabitethernet 1/0/1 [DeviceA-vlan100] quit

创建VLAN 200,并将GigabitEthernet1/0/2 加入VLAN 200。

[DeviceA] vlan 200 [DeviceA-vlan200] port gigabitethernet 1/0/2 [DeviceA-vlan200] quit

为了使Device A 上VLAN 100 和VLAN 200 的报文能发送给Device B , 将

GigabitEthernet1/0/3 的链路类型配置为Trunk,并允许VLAN 100 和VLAN 200 的报文通过。 [DeviceA] interface gigabitethernet 1/0/3 [DeviceA-GigabitEthernet1/0/3] port link-type trunk [DeviceA-GigabitEthernet1/0/3] port trunk permit vlan 100 200

(2) Device B 上的配置与Device A 上的配置相同。

(3) 将Host A 和Host C 配置在一个网段,比如192.168.100.0/24;将Host B 和Host D 配置在 一个网段,比如192.168.200.0/24。 3. 验证配置 (1) Host A 和Host C 能够互相ping 通,但是均不能ping 通Host B。Host B 和Host D 能够互相 ping 通,但是均不能ping 通Host A。 (2) 通过查看显示信息验证配置是否成功。

查看Device A 上VLAN 100 和VLAN 200 的配置信息,验证以上配置是否生效。

[DeviceA-Ten-GigabitEthernet1/0/3] display vlan 100 VLAN ID: 100 VLAN type: Static Route interface: Not configured Description: VLAN 0100 Name: VLAN 0100 Tagged ports: Ten-GigabitEthernet1/0/3 1-13 Untagged ports: Ten-GigabitEthernet1/0/1 [DeviceA-Ten-GigabitEthernet1/0/3] display vlan 200 VLAN ID: 200 VLAN type: Static Route interface: Not configured Description: VLAN 0200 Name: VLAN 0200 Tagged ports: Ten-GigabitEthernet1/0/3 Untagged ports: Ten-GigabitEthernet1/0/2