一、配置拓撲
二、 關鍵配置
1、配置VLAN、Trunk
1)、SW1的配置
SW1#show vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Et0/3
10 VLAN0010 active
20 VLAN0020 active
interface Ethernet0/0 //交換機互聯接口配置為Trunk
switchport trunk encapsulation dot1q
switchport mode trunk
DHCP服務端口配置為Access vlan30
interface Ethernet0/1
switchport access vlan 30
switchport mode access
2、SW1的VLANIF配置
3、SW2的配置
劃分接口VLAN:
interface Ethernet0/1
switchport access vlan 10
switchport mode access
interface Ethernet0/2
switchport access vlan 20
switchport mode access
配置Trunk:
interface Ethernet0/0
switchport trunk encapsulation dot1q
switchport mode trunk
4、DHCP服務器配置
ip dhcp pool VLAN10 //配置地址池分配IP地址段及掩碼DNS
network 192.168.10.0 255.255.255.0
default-router 192.168.10.254
dns-server 8.8.8.8
lease 7
ip dhcp pool VLAN20 //配置地址池分配IP地址段及掩碼DNS
network 192.168.20.0 255.255.255.0
default-router 192.168.20.254
dns-server 8.8.8.8
lease 7
ip dhcp excluded-address 192.168.10.254 //排除地址
ip dhcp excluded-address 192.168.20.254
配置DHCP中繼:
interface Vlan10
ip address 192.168.10.254 255.255.255.0
ip helper-address 192.168.30.1
interface Vlan20
ip address 192.168.20.254 255.255.255.0
ip helper-address 192.168.30.1
三、DHCP測試
PC1可以正常獲取IP地址
PC2可以正常獲取IP地址
PC2(config-if)#
*Aug 29 07:58:03.838: %DHCP-6-ADDRESS_ASSIGN: Interface Ethernet0/2 assigned DHCP address 192.168.20.1, mask 255.255.255.0, hostname PC2