实验如下:
配置交换 部署思路:
1.交换机创建VLAN
2.将交换机上的各个接口划分到对应vlan中
3.trunk 干道
4.vlan间路由创建子接口
所有我们开始搭建:
要求:
1.PC1与PC3所在接口为access,PVID 与VLAN2
2.PC4 5 6处于同一网段;其中PC2可以访问PC4 5 6 PC4可以访问PC5 不能访问PC6 PC5不能访问PC6
3.PC 13与PC 2456不在同一网段
4.所有IP都需要DHCP来获取IP
我们先开始对SW1进行配置:
首先创建VLAN
[sw1]vlan b 2 to 5
然后进入接口开始划分vlan:
[sw1-Ethernet0/0/1]port link-type access
[sw1-Ethernet0/0/1]port de vlan 2
[sw1-Ethernet0/0/2]port link-type hybrid
[sw1-Ethernet0/0/2]port hybrid pvid vlan 3
[sw1-Ethernet0/0/2]port hybrid untagged vlan 2 to 6
[sw1-Ethernet0/0/3]port link-type trunk
[sw1-Ethernet0/0/3]port trunk allow-pass vlan all
重点:
[sw1-Ethernet0/0/4]port link-type hybrid
[sw1-Ethernet0/0/4]port hybrid tagged vlan 2
[sw1-Ethernet0/0/4]port hybrid untagged vlan 3 to 6
切记:华为设备中,若路由器上配置了子接口,每个子接口均会定义管理的VID;
若存在子接口的物理接口,接受到数据包中不存在vlan封装,将由物理接口管理
对SW2:
[sw2]vlan b 2 to 6
[sw2-Ethernet0/0/2]port link-type access
[sw2-Ethernet0/0/2]port default vlan 2
[sw2-Ethernet0/0/3]port link-type hybrid
[sw2-Ethernet0/0/3]port hybrid pvid vlan 4
[sw2-Ethernet0/0/3]port hybrid untagged vlan 2 to 5
[sw2-Ethernet0/0/4]port link-type trunk
[sw2-Ethernet0/0/4]port trunk allow-pass vlan all
对SW3:
[sw3]vlan batch 2 to 6
[sw3-Ethernet0/0/2]port link-type hybrid
[sw3-Ethernet0/0/2]port hybrid pvid vlan 5
[sw3-Ethernet0/0/2]port hybrid untagged vlan 2 to 5
[sw3-Ethernet0/0/3]port link-type hybrid
[sw3-Ethernet0/0/3]port hybrid pvid vlan 6
[sw3-Ethernet0/0/3]port hybrid untagged vlan 2 to 3 6
[sw3-Ethernet0/0/1]port link-type trunk
[sw3-Ethernet0/0/1]port trunk allow-pass vlan all
这时候我们已经把交换全部配完 开始配置路由
[r1]int g0/0/0.1
[r1-GigabitEthernet0/0/0.1]dot1q termination vid 2
[r1-GigabitEthernet0/0/0.1]ip add 192.168.1.1 24
[r1-GigabitEthernet0/0/0.1]arp broadcast enable
[r1-GigabitEthernet0/0/0.1]q
[r1]ip pool a
[r1-ip-pool-a]network 192.168.1.0 m 24
[r1-ip-pool-a]g
[r1-ip-pool-a]gateway-list 192.168.1.1
[r1-ip-pool-a]dns 8.8.8.8
[r1-ip-pool-a]q
[r1]int g0/0/0.1
[r1-GigabitEthernet0/0/0.1]dhcp s g
[r1-GigabitEthernet0/0/0.1]q
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 192.168.2.1 24
[r1-GigabitEthernet0/0/0]q
[r1]ip pool b
[r1-ip-pool-b]network 192.168.2.0 m 24
[r1-ip-pool-b]gateway-list 192.168.2.1
[r1-ip-pool-b]dns 8.8.8.8
[r1-ip-pool-b]q
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]dhcp s g
这时候我们看PC1的IP:
对PC2 电脑:
对PC 5 和 PC 6如下
然后开始看要求PING
我们用PC4 来ICMP 5 6如图
然后用PC5 ICMP 6
发现不通
故实验全部完成!