Dynamic Host Configuration Protocol (DHCP) allows a router to automatically assign IP addresses and other network parameters (such as default gateway and DNS server) to hosts. In a router-on-a-stick setup, one physical interface on the router is divided into multiple subinterfaces, each subinterface corresponding to a VLAN. The router will act as a DHCP server for each VLAN.

Create Subinterfaces for VLANs
Router0> enable Router0# configure terminal ! ! Subinterface for VLAN 100 Router0(config)# interface FastEthernet0/0.100 Router0(config-subif)# encapsulation dot1Q 100 Router0(config-subif)# ip address 192.168.100.1 255.255.255.0 Router0(config-subif)# no shutdown ! ! Subinterface for VLAN 150 Router0(config)# interface FastEthernet0/0.150
Router0(config-subif)# encapsulation dot1Q 150 Router0(config-subif)# ip address 192.168.150.1 255.255.255.0 Router0(config-subif)# no shutdown !
Exclude Addresses
Router0(config)# ip dhcp excluded-address 192.168.100.1 192.168.100.10
Router0(config)# ip dhcp excluded-address 192.168.150.1 192.168.150.10
(We exclude the router’s own IP within the small range)
Create DHCP Pools
Router0 is acting as a DHCP server for two VLANs (100 and 150).
Each VLAN has its own network range and default gateway.
Both VLANs share the same DNS server (8.8.8.8).
When PCs in VLAN 100 or VLAN 150 boot up and send a DHCP request, the router will hand out an IP from the correct pool, along with gateway and DNS info.
Switch> enable Switch# configure terminal Switch(config)# interface FastEthernet0/1
Switch(config-if)# switchport mode trunk Switch(config-if)# no shutdown
Use the following commands on Router0 to ensure everything is working.
Show IP Interface Brief
Show IP DHCP Binding
After hosts have obtained an IP address, you should see entries similar to:
Show Running Configuration (Section DHCP)
Useful for checking your DHCP pools:
Ping Tests
From each host, you should be able to ping the router interfaces (192.168.100.1 or 192.168.150.1) and potentially other hosts in the same VLAN.
Forgetting to Create/Enable Subinterfaces
Incorrect or Missing Excluded Addresses
No DHCP Pool or Incorrect Network Statement
Switchport Not in the Correct VLAN Mode
The lab is available for download from this link.
Before the next lesson, try the following to reinforce your DHCP knowledge:
Add Another VLAN (e.g., VLAN 200)
Change the DNS Server