实验需求
- PC1、PC3属于VLAN 2;
- PC2、PC4属于VLAN 3;
- 通过DHCP使得PC获取IP地址信息
- 全网可达
实验步骤
创建vlan
[SW1]vlan batch 2 3
[SW1-GigabitEthernet0/0/3]port link-type access
[SW1-GigabitEthernet0/0/3]port default vlan 2
[SW1-GigabitEthernet0/0/4]port li ac
[SW1-GigabitEthernet0/0/4]port default vlan 3
[SW1-GigabitEthernet0/0/2]po li t
[SW1-GigabitEthernet0/0/2]port trunk allow-pass vlan 2 3
[SW1-GigabitEthernet0/0/1]po li t
[SW1-GigabitEthernet0/0/1]po t all v 2 3
[SW2]vlan batch 2 3
[SW2-GigabitEthernet0/0/2]port link-type access
[SW2-GigabitEthernet0/0/2]port default vlan 2
[SW2-GigabitEthernet0/0/3]po li ac
[SW2-GigabitEthernet0/0/3]po de v 3
[SW2-GigabitEthernet0/0/1]port link-type trunk
[SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3
相关配置
[r1]ip pool vlan2
[r1-ip-pool-vlan2]network 192.168.2.0 mask 24
[r1-ip-pool-vlan2]gateway-list 192.168.2.254
[r1-ip-pool-vlan2]dns-list 8.8.8.8
[r1-ip-pool-vlan3]network 192.168.3.0 mask 24
[r1-ip-pool-vlan3]gateway-list 192.168.3.254
[r1-ip-pool-vlan3]dns-list 8.8.8.8
[r1]int e 0/0/0.1
[r1-Ethernet0/0/0.1]ip address 192.168.2.254 24
[r1-Ethernet0/0/0.1]dot1q termination vid 2
[r1-Ethernet0/0/0.1]arp broadcast enable
[r1-Ethernet0/0/0.1]dhcp select global
[r1]int e 0/0/0.2
[r1-Ethernet0/0/0.2]ip address 192.168.3.254
[r1-Ethernet0/0/0.2]dot1q termination vid 3
[r1-Ethernet0/0/0.2]arp broadcast enable
[r1-Ethernet0/0/0.2]dhcp select global