例图
实验需求
1.pc1、pc3属于vlan 2
2.pc2、pc4属于vlan 3
3.通过DHCP使得PC获取IP地址信息
4.全网可达
实验分析
1.利用VLAN将广播域进行分割
2.网关手工配置,通过DHCP分配pc设备IP地址
3.创建虚拟接口,完成相应配置
4.检查所有设备是否联通
实验配置
DHCP配置---AR1
[jia]dhcp enable
[jia]ip pool jia1
[jia-ip-pool-jia1]network 192.168.1.0 mask 24
[jia-ip-pool-jia1]gateway-list 192.168.1.254
[jia-ip-pool-jia1]dns-list 8.8.8.8
[jia]ip pool jia2
[jia-ip-pool-jia2]network 192.168.2.0 mask 24
[jia-ip-pool-jia2]gateway-list 192.168.2.254
[jia-ip-pool-jia2]dns-list 8.8.8.8
VLAN配置
[LSW1]int g0/0/2
[LSW1-GigabitEthernet0/0/2]port link-type access
[LSW1-GigabitEthernet0/0/2]port default vlan 2
[LSW1-GigabitEthernet0/0/2]int g0/0/3
[LSW1-GigabitEthernet0/0/3]port link-type access
[LSW1-GigabitEthernet0/0/3]port default vlan 3
[LSW2]int g0/0/2
[LSW2-GigabitEthernet0/0/2]port link-type access
[LSW2-GigabitEthernet0/0/2]port default vlan 2
[LSW2-GigabitEthernet0/0/2]int g0/0/3
[LSW2-GigabitEthernet0/0/3]port link-type access
[LSW2-GigabitEthernet0/0/3]port default vlan 3
配置连接LSW1与LSW2的通道
[LSW1]int g0/0/4
[LSW1-GigabitEthernet0/0/4]port link-type trunk
[LSW1-GigabitEthernet0/0/4]port trunk allow-pass vlan 2 3
[LSW2]int g0/0/1
[LSW2-GigabitEthernet0/0/1]port link-type trunk
[LSW2-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3
配置LSW1与AR1的通道
[LSW1]int g0/0/1
[LSW1-GigabitEthernet0/0/1]port link-type trunk
[LSW1-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3
创建AR1的2个子接口
[jia]int g0/0/0.1
[jia-GigabitEthernet0/0/0.1]ip add 192.168.1.254 24
[jia-GigabitEthernet0/0/0.1]dot1q termination vid 2
[jia-GigabitEthernet0/0/0.1]arp broadcast enable
[jia-GigabitEthernet0/0/0.1]int g0/0/0.2
[jia-GigabitEthernet0/0/0.2]ip add 192.168.2.254 24
[jia-GigabitEthernet0/0/0.2]dot1q termination vid 3
[jia-GigabitEthernet0/0/0.2]arp broadcast enable
启动DHCP
在子接口启动DHCP,将地址分配给vlan2 3中的pc端
实验验证
“ipconfig” 查询电脑IP地址
pc1
pc2
pc3
pc4
“ping x.x.x.x” 验证是否能够到达该地址
用pc1去访问pc2 pc3 pc4