拓扑:

需求:
MSW1
MSW1(config)#interface ethernet 0/0
MSW1(config-if)#switchport trunk encapsulation dot1q
MSW1(config-if)#switchport mode trunk
SW2
SW2(config)#interface ethernet 0/0
SW2(config-if)#switchport trunk encapsulation dot1q
SW2(config-if)#switchport mode trunk
MSW1
MSW1(config)#vlan 10,20
MSW1(config-vlan)#interface vlan 10
MSW1(config-if)#ip address 192.168.10.254 255.255.255.0
MSW1(config-if)#no shutdown
MSW1(config-if)#interface vlan 20
MSW1(config-if)#ip address 192.168.20.254 255.255.255.0
MSW1(config-if)#no shutdown
SW2
SW2(config)#interface ethernet 0/1
SW2(config-if)#switchport mode access
SW2(config-if)#switchport access vlan 10
% Access VLAN does not exist. Creating vlan 10
SW2(config-if)#interface ethernet 0/2
SW2(config-if)#switchport mode access
SW2(config-if)#switchport access vlan 20
% Access VLAN does not exist. Creating vlan 20
MSW1
创建DHCP地址池
MSW1(config)#ip dhcp pool Produce
MSW1(dhcp-config)#network 192.168.10.0 /24
MSW1(dhcp-config)#default-router 192.168.10.254
MSW1(dhcp-config)#dns-server 114.114.114.114
MSW1(config)#ip dhcp pool Office
MSW1(dhcp-config)#network 192.168.20.0 /24
MSW1(dhcp-config)#default-router 192.168.20.254
MSW1(dhcp-config)#dns-server 114.114.114.114
移除不下发IP地址
MSW1(config)#ip dhcp excluded-address 192.168.10.254
MSW1(config)#ip dhcp excluded-address 192.168.20.254
PC1、PC2使用DHCP获取IP
PC1
PC1(config)#interface ethernet 0/1
PC1(config-if)#ip address dhcp
PC1(config-if)#no shutdown
PC2
PC2(config)#interface ethernet 0/2
PC2(config-if)#ip address dhcp
PC2(config-if)#no shutdown
相关课程内容推荐
思科认证备考须知:CCNA 备考指南
思博全新思科课程399活动价限额限时优惠:新版CCNA 课程
思博CCNA课程安排表: CCNA课表
网工必备证书:什么是思科认证CCNA
天津CCNA培训考试指南:天津CCNA培训机构如何选择? | 天津ccna考试地点在哪?
即刻预约
免费试听-咨询课程-获取免费资料