Dynamic Host Configuration Protocol (DHCP) is a protocol based on client/server architecture used to facilitate the allocation of IP addresses in a network. A local network that does not use DHCP must provide IP addresses to all computers manually. If DHCP is installed on a local network, all computers connected to the network will get an IP address automatically from the DHCP server. Besides IP addresses, DHCP also provides parameters, such as default gateways and DNS servers.
VLAN allows networks to be segmented and formed into logical groups of users, regardless of the user’s physical location or LAN connection.
In this tutorial, we will configure:
- Create 3 VLANs and add a PC to each VLAN
- DHCP Server Configuration on Router
- Assign DHCP Pool on each VLAN
- PC Configuration as DHCP Client
- Connection Test
Other Interesting Articles
VLAN configuration on Switch
Create 3 VLANs on switches: VLAN 10, VLAN 20, and VLAN 30.
Switch#en Switch#conf t Switch(config)#vlan 10 Switch(config-vlan)#exit Switch(config)#vlan 20 Switch(config-vlan)#exit Switch(config)#vlan 30 Switch(config-vlan)#exit Switch(config) #
Set VLAN 10 ports on Fa0/1 interface, VLAN 20 on Fa0/2 interface, VLAN 30 on Fa0/3 interface, and on Fa0/4 interface (interface connected to the router) set TRUNK mode.
Switch>en Switch#conf t Switch(config)#int fa0/1 Switch(config-if)#switchport access vlan 10 Switch(config-if)#exit Switch(config)#int fa0/2 Switch(config-if)#switchport access vlan 20 Switch(config-if)#exit Switch(config)#int fa0/3 Switch(config-if)#switchport access vlan 30 Switch(config-if)#exit Switch(config)#int fa0/4 Switch(config-if)#switchport trunk mode Switch(config-if)#exit
Check the VLAN you’ve made.
Switch#sh vlan VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------- 1 default active Fa0/5, Fa0/6, Fa0/7, Fa0/8 Fa0/9, Fa0/10, Fa0/11, Fa0/12 Fa0/13, Fa0/14, Fa0/15, Fa0/16 Fa0/17, Fa0/18, Fa0/19, Fa0/20 Fa0/21, Fa0/22, Fa0/23, Fa0/24 Gig0/1, Gig0/2 10 VLAN0010 active Fa0/1 20 VLAN0020 active Fa0/2 30 VLAN0030 active Fa0/3
Check the trunk mode interface
Switch#sh int trunk Port Mode Encapsulation Status Native vlan Fa0/4 on 802.1q trunking 1 Port Vlans allowed on trunk Fa0/4 1-1005 Port Vlans allowed and active in domain management Fa0/4 1,10,20,30 Port Vlans in spanning tree forwarding state and not pruned Fa0/4 1,10,20,30
DHCP Server Configuration on Router
The first step we do is to configure the interface on the router. In the example above, the router is connected to a switch on the Gi0/0 port. In the Gi0/0 interface, we create 3 subinterfaces: Gi0/0.10, Gi0/0.20, and Gi0/0.30 with IP 192.168.10.1, 192.168.20.1, and 192.168.30.1.
Router#en Router#conf t Router(config)#int Gi0/0 Router(config-if)#no ip add Router(config-if)#no shut Router(config-if)#int Gi0/0.10 Router(config-subif)# Router(config-subif)#en dot1q 10 Router(config-subif)#ip add 192.168.10.1 255.255.255.0 Router(config-subif)#exit Router(config)#int Gi0/0 Router(config-if)#int Gi0/0.20 Router(config-subif)#en dot1q 20 Router(config-subif)#ip add 192.168.20.1 255.255.255.0 Router(config-subif)#exit Router(config)#int Gi0/0 Router(config-if)#int Gi0/0.30 Router(config-subif)#ip add 192.168.30.1 255.255.255.0 Router(config-subif)#exit Router(config) #
Next, the DHCP server configuration is as follows.
Router#en Router#conf t Router(config)#ip dhcp pool POOL10 Router(dhcp-config)#network 192.168.10.0 255.255.255.0 Router(dhcp-config)#default-router 192.168.10.1 Router(dhcp-config)#dns-server 8.8.8.8 Router(dhcp-config)#exit Router(config)#ip dhcp excluded-address 192.168.10.1 Router(config)#ip dhcp pool POOL20 Router(dhcp-config)#network 192.168.20.0 255.255.255.0 Router(dhcp-config)#default-router 192.168.20.1 Router(dhcp-config)# Router(dhcp-config)#dns-server 8.8.8.8 Router(dhcp-config)#exit Router(config)#ip dhcp excluded-address 192.168.20.1 Router(config)#ip dhcp pool POOL30 Router(dhcp-config)#network 192.168.30.0 255.255.255.0 Router(dhcp-config)#default-router 192.168.30.1 Router(dhcp-config)#dns-server 8.8.8.8 Router(dhcp-config)#exit Router(config)#ip dhcp excluded-address 192.168.30.1 Router(config) #
PC Configuration as DHCP Client
Click the “Desktop” tab, then select “IP Configuration”.
Select “DHCP” (1), if successful there will be a notification “DHCP request successful” (2). Next at point (3) will be displayed IP and other parameters of DHCP Server.
Connection Test
To perform a connection test, you can ping from PC0 (192.168.10.2) to PC1 (192.168.20.2)