VLAN虚拟局域网

要求如下 

VLAN虚拟局域网_第1张图片

在交换机上创建vlan2,vlan3        分别把对应接口划分到对应vlan

[Huawei]vlan batch 2 to 3
[Huawei]port-group group-member Ethernet 0/0/1 to Ethernet 0/0/2
[Huawei-port-group]port link-type access
[Huawei-port-group]port default vlan 2
[Huawei-port-group]q
[Huawei]port-group group-member Ethernet 0/0/3 to Ethernet 0/0/4
[Huawei-port-group]port link-type access
[Huawei-port-group]port default vlan 3
[Huawei-port-group]q

建立trunk干道,如下图交换机1的配置

[Huawei-Ethernet0/0/5]port link-type trunk
[Huawei-Ethernet0/0/5]port trunk allow-pass vlan 2 to 3
[Huawei]interface Ethernet0/0/6
[Huawei-Ethernet0/0/6]port link-type trunk
[Huawei-Ethernet0/0/6]port trunk allow-pass vlan 2 to 3

给路由器放两个子接口

[Huawei]interface GigabitEthernet 0/0/0.1
[Huawei-GigabitEthernet0/0/0.1]dot1q termination vid 2
[Huawei-GigabitEthernet0/0/0.1]ip add 192.168.1.1 24
[Huawei-GigabitEthernet0/0/0.1]arp broadcast enable
[Huawei]interface GigabitEthernet 0/0/0.2
[Huawei-GigabitEthernet0/0/0.2]dot1q termination vid 3
[Huawei-GigabitEthernet0/0/0.2]ip add 192.168.2.1 24
[Huawei-GigabitEthernet0/0/0.2]arp broadcast enable

题目还要求DHCP自动获取ip,可以在路由器中进行配置

[Huawei]dhcp enable
[Huawei]ip pool a
[Huawei-ip-pool-a]network 192.168.1.0 mask 24
[Huawei-ip-pool-a]gateway-list 192.168.1.1
[Huawei-ip-pool-a]dns-list 114.114.114.114
[Huawei-ip-pool-a]q
[Huawei]ip pool b
[Huawei-ip-pool-b]network 192.168.1.0 mask 24
[Huawei-ip-pool-b]gateway-list 192.168.2.1
[Huawei-ip-pool-b]dns-list 114.114.114.114
[Huawei-ip-pool-b]q
[Huawei]interface GigabitEthernet 0/0/0.1
[Huawei-GigabitEthernet0/0/0.1]dhcp select global
[Huawei-GigabitEthernet0/0/0.1]q
[Huawei]interface GigabitEthernet 0/0/0.2
[Huawei-GigabitEthernet0/0/0.2]dhcp select global
[Huawei-GigabitEthernet0/0/0.2]q

最后在电脑上开启DHCP服务 

VLAN虚拟局域网_第2张图片

可以看到已经成功自动获取IP 

 VLAN虚拟局域网_第3张图片

 最终再用第一个电脑ping一下最后一个电脑

VLAN虚拟局域网_第4张图片

此时这个实验完美结束 

你可能感兴趣的:(网络,p2p,网络协议,网络)