一、实验拓扑图及实验需求
1.拓扑图:
2.需求:
PC1、PC3属于VLAN 2
PC2、PC4属于VLAN 3
通过DHCP使得pc获取IP地址信息
全网可达
二、需求分析
1.整张拓扑图分为两个广播域,在路由器上增加两个子接口
2.将PC1和PC3划分到VLAN2中,将PC2和PC4划分到VLAN3中
3.将交换机的接口划入到相关VLAN内部,以及配置干道
4.并使用DHCP为PC分配IP
5.定义两个子接口所能处理的VLAN信息
6.全网可达
三、实验步骤
1.在路由器上创建两个子接口,给路由器添加地址池
[r1]interface g 0/0/0.1
[r1-GigabitEthernet0/0/0.1]ip address 192.168.1.100 24
[r1-GigabitEthernet0/0/0.1]QUIT
[r1]interface g 0/0/0.2
[r1-GigabitEthernet0/0/0.2]ip address 192.168.2.100 24
[r1-GigabitEthernet0/0/0.2]quit
[r1]dhcp enable
[r1]ip pool wjk
[r1-ip-pool-wjk]network 192.168.1.0 mask 24
[r1-ip-pool-wjk]gateway-list 192.168.1.100
[r1-ip-pool-wjk]dns-list 8.8.8.8
[r1-ip-pool-wjk]quit
[r1]interface GigabitEthernet 0/0/0.1
[r1-GigabitEthernet0/0/0.1]dhcp select global
[r1-GigabitEthernet0/0/0.1]quit
[r1]dhcp enable
[r1]ip pool wy
[r1-ip-pool-wy]network 192.168.2.0 mask 24
[r1-ip-pool-wy]gateway-list 192.168.2.100
[r1-ip-pool-wy]dns-list 8.8.8.8
[r1-ip-pool-wy]quit
[r1]interface GigabitEthernet 0/0/0.2
[r1-GigabitEthernet0/0/0.2]dhcp select global
2.将PC1和PC3划分到VLAN2中,将PC2和PC4划分到VLAN3中,以及将交换机LSW1和LSW2的接口划入到相关VLAN内部
[LSW1]vlan batch 2 3
[LSW1]interface GigabitEthernet 0/0/2
[LSW1-GigabitEthernet0/0/2]port link-type access
[LSW1-GigabitEthernet0/0/2]port default vlan 2
[LSW1-GigabitEthernet0/0/2]int g 0/0/3
[LSW1-GigabitEthernet0/0/3]port link-type access
[LSW1-GigabitEthernet0/0/3]port default vlan 3
[LSW1-GigabitEthernet0/0/4]int g 0/0/1
[LSW1-GigabitEthernet0/0/1]port link-type trunk
[LSW1-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3
[LSW2]vlan batch 2 3
[LSW2]interface GigabitEthernet 0/0/2
[LSW2-GigabitEthernet0/0/2]port link-type access
[LSW2-GigabitEthernet0/0/2]port default vlan 2
[LSW2-GigabitEthernet0/0/2]int g 0/0/3
[LSW2-GigabitEthernet0/0/3]port link-type access
[LSW2-GigabitEthernet0/0/3]port default vlan 3
[LSW2-GigabitEthernet0/0/3]int g 0/0/1
[LSW2-GigabitEthernet0/0/1]port link-type trunk
[LSW2-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3
3.配置干道
[LSW1-GigabitEthernet0/0/3]int g 0/0/4
[LSW1-GigabitEthernet0/0/4]port link-type trunk
[LSW1-GigabitEthernet0/0/4]port trunk allow-pass vlan 2 3
5.定义两个子接口所能处理的VLAN信息
[r1]int g 0/0/0.1
[r1-GigabitEthernet0/0/0.1]dot1q termination vid 2
[r1-GigabitEthernet0/0/0.1]arp broadcast enable
[r1-GigabitEthernet0/0/0.1]int g 0/0/0.2
[r1-GigabitEthernet0/0/0.2]dot1q termination vid 3
[r1-GigabitEthernet0/0/0.2]arp broadcast enable