实验拓扑
实验需求
1、C1与C3属于VLAN10,C2与C4属于VLAN20,在SW1上创建VLAN100做上行VLAN
2、在SW1上终结所有VLAN
3、在所有VLAN成员使用DHCP获取IP
4、全网互通
IP规划
VLAN10 :192.168.10.0/24
VLAN20 :192.168.20.0/24
VLAN100:192.168.100.10/24
R1 G0/0/0:192.168.100.1/24
SW1配置:
[SW1]vlan batch 10 20 100 //创建VLAN
[SW1]dhcp enable //开启DHCP服务
[SW1]inter g0/0/1
[SW1-GigabitEthernet0/0/1]port hybrid pvid vlan 10
[SW1-GigabitEthernet0/0/1]port hybrid untagged vlan 10 //将接口以untagged方式加入vlan
[SW1-GigabitEthernet0/0/1]int g0/0/2
[SW1-GigabitEthernet0/0/2]port hybrid pvid vlan 20
[SW1-GigabitEthernet0/0/2]port hybrid untagged vlan 20
[SW1-GigabitEthernet0/0/2]int g0/0/10
[SW1-GigabitEthernet0/0/10]port hybrid pvid vlan 100
[SW1-GigabitEthernet0/0/10]port hybrid untagged vlan 100
[SW1-GigabitEthernet0/0/10]int g0/0/24
[SW1-GigabitEthernet0/0/24]port hybrid tagged vlan 10 20 //将接口以tagged方式加入vlan
[SW1-GigabitEthernet0/0/24]quit
[SW1]inter vlan 10 //进入vlan10
[SW1-Vlanif10]ip address 192.168.10.1 24 //配置vlan10成员的网关
[SW1-Vlanif10]dhcp select interface //将dhcp应用在接口
[SW1-Vlanif10]int vlan 20
[SW1-Vlanif20]ip address 192.168.20.1 24
[SW1-Vlanif20]dhcp select interface
[SW1-Vlanif20]int vlan 100
[SW1-Vlanif100]ip address 192.168.100.10 24
SW2配置:
[SW2]vlan batch 10 20
[SW2]inter g0/0/1
[SW2-GigabitEthernet0/0/1]port hybrid pvid vlan 10
[SW2-GigabitEthernet0/0/1]port hybrid untagged vlan 10
[SW2-GigabitEthernet0/0/1]int g0/0/2
[SW2-GigabitEthernet0/0/2]port hybrid pvid vlan 20
[SW2-GigabitEthernet0/0/2]port hybrid untagged vlan 20
[SW2-GigabitEthernet0/0/2]int g0/0/24
[SW2-GigabitEthernet0/0/24]port hybrid tagged vlan 10 20
R1配置:
[R1]ip route-static 0.0.0.0 0.0.0.0 192.168.100.10
[R1]inter G0/0/0
[R1-GigabitEthernet0/0/0]ip address 192.168.100.1 24
测试: