目录
实验拓扑:
实验目的:
实验思路:
实验步骤:
1.创建VLAN
2.将接口放进相应VLAN当中,并配置接口类型(hybrid口配置撕tag表)
3.配置路由器接口
4.配置DHCP服务
pc1 ping pc4的过程分析:
实验拓扑:
实验目的:
1、pc1和pc3所在接口为access;属于vlan2;
pc2/pc4/pc5/pc6处于同一网段:其中pc2可以访问pc4/pc5/pc6;
2、pc1/pc3与pc2/pc4/pc5/pc6不在同一网段;
3、所有pc通过DHCP获职IP地址,且pc1/pc3可以正常访问pc2/pc4/pc5/pc6;
实验思路:
1.创建vlan(因通信需求在LSW1/LSW2/LSW3都需要创建VLAN2-6)
2.将交换机的接口放进相应的VLAN当中,
LSW1的g0/0/1和LSW2的g0/0/1为access类型
LSW1、LSW2、LSW3相连的接口类型为trunk类型
LSW1的g0/0/2和g0/0/4、LSW2的g0/0/2、LSW3的g0/0/1和g0/0/2均为hybrid类型(根据需要通信的pc写untagged表)
LSW1的g0/0/4口配置:因为子接口只能给一个vlan,将子接口给vlan 2,物理口给其他vlan
3.配置路由器(物理口为VLAN3/4/5/6服务,子接口为VLAN2服务)
4.配置DHCP服务
实验步骤:
1.创建VLAN
[sw1]vlan batch 2 to 6
[sw2]vlan batch 2 to 6
[sw3]vlan batch 2 to 6
2.将接口放进相应VLAN当中,并配置接口类型(hybrid口配置撕tag表)
[sw1]int g0/0/1
[sw1-GigabitEthernet0/0/1]port link-type access
[sw1-GigabitEthernet0/0/1]port default vlan 2
[sw1-GigabitEthernet0/0/1]int g0/0/2
[sw1-GigabitEthernet0/0/2]port hybrid pvid vlan 3
[sw1-GigabitEthernet0/0/2]port hybrid untagged vlan 3 to 6
[sw1-GigabitEthernet0/0/2]int g0/0/3
[sw1-GigabitEthernet0/0/3]port link-type trunk
[sw1-GigabitEthernet0/0/3]port trunk allow-pass vlan 2 to 6
[sw1]int g0/0/4
[sw1-GigabitEthernet0/0/4]port hybrid untagged vlan 3 to 6
[sw1-GigabitEthernet0/0/4]port hybrid tagged vlan 2
[sw2]int g0/0/1
[sw2-GigabitEthernet0/0/1]port link-type access
[sw2-GigabitEthernet0/0/1]port default vlan 2
[sw2-GigabitEthernet0/0/1]int g0/0/2
[sw2-GigabitEthernet0/0/2]port hybrid pvid vlan 4
[sw2-GigabitEthernet0/0/2]port hybrid untagged vlan 3 to 6
[sw2-GigabitEthernet0/0/2]int g0/0/3
[sw2-GigabitEthernet0/0/3]port link-type trunk
[sw2-GigabitEthernet0/0/3]port trunk allow-pass vlan 2 to 6
[sw2-GigabitEthernet0/0/3]int g0/0/4
[sw2-GigabitEthernet0/0/4]port link-type trunk
[sw2-GigabitEthernet0/0/4]port trunk allow-pass vlan 2 to 6
[sw3]int g0/0/1
[sw3-GigabitEthernet0/0/1]port hybrid pvid vlan 5
[sw3-GigabitEthernet0/0/1]port hybrid untagged vlan 3 to 5
[sw3-GigabitEthernet0/0/1]int g0/0/2
[sw3-GigabitEthernet0/0/2]port hybrid pvid vlan 6
[sw3-GigabitEthernet0/0/2]port hybrid untagged vlan 3 4 6
[sw3-GigabitEthernet0/0/2]int g0/0/3
[sw3-GigabitEthernet0/0/3]port link-type trunk
[sw3-GigabitEthernet0/0/3]port trunk allow-pass vlan 2 to 6
3.配置路由器接口
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 192.168.1.254 24
[r1-GigabitEthernet0/0/0]int g0/0/0.1
[r1-GigabitEthernet0/0/0.1]ip add 192.168.2.254 24
[r1-GigabitEthernet0/0/0.1]dot1q termination vid 2
[r1-GigabitEthernet0/0/0.1]arp broadcast enable
4.配置DHCP服务
将192.168.1.0网段给物理口,192.168.2.0网段给子接口
[r1]dhcp enable
[r1]ip pool v3456
[r1-ip-pool-v3456]network 192.168.1.0 mask 24
[r1-ip-pool-v3456]gateway-list 192.168.1.254
[r1-ip-pool-v3456]dns-list 8.8.8.8 114.114.114.114
[r1-GigabitEthernet0/0/0]dhcp select global
[r1]ip pool v2
[r1-ip-pool-v2]network 192.168.2.0 mask 24
[r1-ip-pool-v2]gateway-list 192.168.2.254
[r1-ip-pool-v2]dns 8.8.8.8 114.114.114.114
[r1]int g0/0/0.1
[r1-GigabitEthernet0/0/0.1]dhcp select global
PC1(vlan 2):
PC2(vlan 3):
PC3(vlan 2):
PC4(vlan 4):
PC5(vlan 5):
PC6(vlan 6):
ping通测试:
pc1 ping pc2/3/4/5/6:
pc1 ping pc4的过程分析:
pc1和pc4不在同一网段,因此需要路由器路由,发出数据的目的mac为R1的子接口(子接口没有mac地址会借相邻接口的mac地址即g0/0/0的地址),发出数据到g0/0/1口被打上vlan 2的标签,带vlan 2标签的数据到交换机根据mac表进行转发,数据到g0/0/4,vlan 2在tagged表中保留vlan 2 tag到达g0/0/0.1口,g0/0/0.1口可以接受带tag的数据,根据路由表进行转发将源mac改为自己目的mac改为pc4的mac地址,g0/0/0.1会将不带标签的数据转发给g0/0/0口,g0/0/0转发到LSW1g0/0/4
g0/0/4口给数据打上vlan 1的标签,交换机转发给g0/0/3口,vlan 1在trunck口的允许列表中,数据到交换机2转发给g0/0/2口,hybrid口会撕掉vlan 1的标签给pc4 ,pc4接受数据。(pc4回包类似)
pc6 ping pc4/5: