一、实验拓扑图及实验需求
实验拓扑图:
实验需求:
- PC1、PC3属于VLAN 2
- PC2、PC4属于VLAN 3
- 通过DHCP使得PC获取IP地址信息
- 全网可达
二、实验分析
- 分配IP地址,将整个网址分为两个广播域,分别为192.168.1.0/24和192.168.2.0/24
- 使用DHCP为PC获取IP地址
- 创建valn,将交换机的接口划入到相关vlan内部,配置干道
- 将PC1、 PC3划分到vlan2,PC2、PC4划分到vlan3
- 为AR1的0/0/0接口划分两个子接口,分别为0/0/0.1和0/0/0.2
- 全网可达
三、实验步骤
1、为AR1的0/0/0接口划分两个子接口,分别为0/0/0.1和0/0/0.2
[R1]interface GigabitEthernet 0/0/0.1
[R1-GigabitEthernet0/0/0.1]ip address 192.168.1.100 24
[R1-GigabitEthernet0/0/0.1]int g 0/0/0.2
[R1-GigabitEthernet0/0/0.2]ip add 192.168.2.100 24
2、创建valn,将PC1、PC3划分到vlan2,PC2、PC4划分到vlan3
PC1划分到vlan2
[sw1]vlan batch 2 3
[sw1]int g 0/0/2
[sw1-GigabitEthernet0/0/2]port link-type access
[sw1-GigabitEthernet0/0/2]port default vlan 2
PC2划分到vlan3
[sw1-GigabitEthernet0/0/2]int g 0/0/3
[sw1-GigabitEthernet0/0/3]port link-type access
[sw1-GigabitEthernet0/0/3]port default vlan 3
PC3划分到vlan2
[sw2]vlan batch 2 3
[sw2]int g 0/0/2
[sw2-GigabitEthernet0/0/2]port link-type access
[sw2-GigabitEthernet0/0/2]port default vlan 2
PC4划分到vlan3
[sw2-GigabitEthernet0/0/2]int g 0/0/3
[sw2-GigabitEthernet0/0/3]port link-type access
[sw2-GigabitEthernet0/0/3]port default vlan 3
3、配置干道
LSW1:
[sw1-GigabitEthernet0/0/3]int g 0/0/4
[sw1-GigabitEthernet0/0/4]port link-type trunk
[sw1-GigabitEthernet0/0/4]port trunk allow-pass vlan 2 3
LSW2:
[sw2-GigabitEthernet0/0/3]int g 0/0/1
[sw2-GigabitEthernet0/0/1]port link-type trunk
[sw2-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3
4、定义子接口所能处理的vlan信息
0/0/0.1子接口:
[R1]int g 0/0/0.1
[R1-GigabitEthernet0/0/0.1]dot1q termination vid 2
[R1-GigabitEthernet0/0/0.1]arp broadcast enable
0/0/0.2子接口:
[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
LSW1 0/0/1接口:
[sw1-GigabitEthernet0/0/4]int g 0/0/1
[sw1-GigabitEthernet0/0/1]port link-type trunk
[sw1-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3
5、使用DHCP为PC获取·IP地址:
[R1]dhcp enable
[R1]ip pool ccy
[R1-ip-pool-ccy]network 192.168.1.0 mask 24
[R1-ip-pool-ccy]gateway-list 192.168.1.100
[R1-ip-pool-ccy]dns-list 8.8.8.8
[R1-ip-pool-ccy]q
[R1]interface g 0/0/0.1
[R1-GigabitEthernet0/0/0.1]dhcp select global
[R1]dhcp enable
[R1]ip pool tr
[R1-ip-pool-tr]network 192.168.2.0 mask 24
[R1-ip-pool-tr]gateway-list 192.168.2.100
[R1-ip-pool-tr]dns-list 8.8.8.8
[R1-ip-pool-tr]q
[R1]interface g 0/0/0.2
[R1-GigabitEthernet0/0/0.2]dhcp select globa
6、全网可达