一、拓补图
二、配置需求
1、PC1、PC3属于VLAN 2
2、PC2、PC4属于VLAN 3
3、通过DHCP使得pc获取IP地址信息
4、全网可达
三、需求分析
1、配交换机
2、划分VLAN
3、配DHCP
4、全网可达(互ping成功)
四、配置过程
[sw1]vlan 2
[sw1]int g 0/0/2
[sw1-GigabitEthernet0/0/2]port link-type access
[sw1-GigabitEthernet0/0/2]port default vlan 2
[sw1]vlan 3
[sw1]int g 0/0/3
[sw1-GigabitEthernet0/0/3]port link-type access
[sw1-GigabitEthernet0/0/3]port default vlan 3
[sw1]int g 0/0/1
[sw1-GigabitEthernet0/0/1]port link-type trunk
[sw1-GigabitEthernet0/0/1]port tu
[sw1-GigabitEthernet0/0/1]port tr
[sw1-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3
[sw1]int g 0/0/4
[sw1-GigabitEthernet0/0/4]port link-type trunk
[sw1-GigabitEthernet0/0/4]port trunk allow-pass vlan 2 3
[sw2]vlan 2
[sw2]int g 0/0/2
[sw2-GigabitEthernet0/0/2]port link-type access
[sw2-GigabitEthernet0/0/2]port default vlan 2
[sw2-vlan3]q
[sw2]int g 0/0/2
[sw2-GigabitEthernet0/0/2]port default vlan 2 3
[sw2]int g 0/0/3
[sw2-GigabitEthernet0/0/3]port link-type access
[sw2-GigabitEthernet0/0/3]port default vlan 3
[sw2-GigabitEthernet0/0/3]q
[sw2]int g 0/0/1
[sw2-GigabitEthernet0/0/1]port link-type trunk
[sw2-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 3
[r1]dhcp enable
[r1]ip pool aa
[r1-ip-pool-aa]network 192.168.1.0 mask 24
[r1-ip-pool-aa]gateway-list 192.168.1.254
[r1-ip-pool-aa]dns-list 8.8.8.8
[r1-ip-pool-aa]q
[r1]int g 0/0/0.2
[r1-GigabitEthernet0/0/0.2]dhcp select global
[r1-GigabitEthernet0/0/0.2]q
[r1]ip pool bb
[r1-ip-pool-bb]network 192.168.2.0 mask 24
[r1-ip-pool-bb]gateway-list 192.168.2.254
[r1-ip-pool-bb]dns-list 8.8.8.8
[r1-ip-pool-bb]q
[r1]int g 0/0/0.3
[r1-GigabitEthernet0/0/0.3]dhcp select global
[r1-GigabitEthernet0/0/0.3]q
五、全网可达