Lab 6 - Understanding and
Configuring DHCP Protocol
Objective
The goal of this lab is to understand the basics of the DHCP protocol and configure
DHCP services. By the end of this lab, you will be able to:
● Set up a DHCP server on a router.
● Configure DHCP pools.
● Assign IP addresses dynamically to client devices.
● Implement VLANs and configure DHCP relay for different network segments.
Part 1: Setting Up a Simple DHCP Network
Topology
1.1 Router Configuration
Step 1: Configure IP Address 192.168.1.1:
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with
CNTL/Z.
Router(config)#interface FastEthernet 0/0
Router(config-if)#no shutdown
Router(config-if)#ip address 192.168.1.1 255.255.255.0
1.2 Configuring DHCP Pool on Router
Step 1: Create a new DHCP pool named “DHCP”:
Router(config)#ip dhcp pool DHCP
Step 2: Specify the network range from which IP addresses will be assigned:
Router(dhcp-config)#network 192.168.1.0 255.255.255.0
Step 3: Set default gateway for the DHCP clients:
Router(dhcp-config)#default-router 192.168.1.1
Step 4: Configure the DNS server address:
Router(dhcp-config)#dns-server 8.8.8.8
Router(dhcp-config)#exit
1.3 Excluding IP Addresses
In this section, we exclude specific IP addresses from being assigned by the DHCP
server. This is useful to reserve IP addresses for important devices like servers,
printers, or the router itself, which typically require static IP addresses.
Step 1: Prevent the DHCP server from assigning the IP address 192.168.1.100 to
any client device, as it might be reserved for a server or important device to avoid
conflicts:
Router(config)#ip dhcp excluded-address 192.168.1.100
Step 2: Excludes the IP address 192.168.1.1 from DHCP pool, since it is the router’s
IP address (default gateway):
Router(config)#ip dhcp excluded-address 192.168.1.1
Router(config)#exit
Step 3: Save Configurations.
Router# write memory
1.4 PC Configuration
Step 1: On each PC, set the IP configuration to DHCP.
Step 2: Display the list of IP addresses that have been dynamically assigned by the
DHCP server:
Router#show ip dhcp binding
IP address Client-ID/ Lease expiration Type
Hardware address
192.168.1.2 0001.42D5.5761 -- Automatic
192.168.1.3 000D.BDCB.92ED -- Automatic
192.168.1.4 0060.3E2E.80E4 -- Automatic
1.5 Test Connectivity
Step 1: Open Command Prompt in PC0.
Step 2: Ping other PCs and gateway addresses.
Part 2: VLAN Configuration with DHCP Relay
Topology
2.1 VLAN Configuration on the Switch
In this part of the lab, we configure multiple VLANs on the switch and assign specific
switchports to these VLANs. Additionally, we configure a trunk port to allow VLAN
traffic to pass between the switch and the router. Below is a breakdown of the
configuration steps, along with explanations.
2.1.1 Create VLANs and Assign Names
Step 1: Create vlan 2:
Switch>enable
Switch#configure terminal
Switch(config)#vlan 2
Switch(config-vlan)#name VLAN2
Switch(config-vlan)#exit
Step 2: Create vlan 3:
Switch(config)#vlan 3
Switch(config-vlan)#name VLAN3
Switch(config-vlan)#exit
Step 3: Create vlan 4 and name it DHCP:
Switch(config)#vlan 4
Switch(config-vlan)#name DHCP
Switch(config-vlan)#exit
2.1.2 Assign VLANs to Switch Ports
Step 1: Assign VLAN 2 to ports FastEthernet 0/2 and FastEthernet 0/3 and set ports
to access mode:
Switch(config)#interface range fastEthernet 0/2-3
Switch(config-if-range)#switchport mode access
Switch(config-if-range)#switchport access vlan 2
Switch(config-if-range)#exit
Step 2: Assign VLAN 3 to ports FastEthernet 0/4 and FastEthernet 0/5 and set ports
to access mode:
Switch(config)#interface range fastEthernet 0/4-5
Switch(config-if-range)#switchport mode access
Switch(config-if-range)#switchport access vlan 3
Switch(config-if-range)#exit
Step 3: Assign VLAN 4 (DHCP) to port FastEthernet 0/6:
Switch(config)#interface FastEthernet 0/6
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 4
2.1.3 Configure the Trunk Port
Step 1: Configure FastEthernet 0/1 as a trunk port:
Switch(config-if)#interface FastEthernet 0/1
Switch(config-if)#switchport mode trunk
Step 2: Specify the allowed VLANs on the trunk:
Switch(config-if)#switchport trunk allowed vlan 2,3,4
Switch(config-if)#exit
2.1.4 Save Configurations
Switch# write memory
2.2 Configuring Sub-Interfaces on the Router for Inter-
VLAN Routing
In this part, we configure the router’s sub-interfaces to allow communication between
different VLANs. This process, known as Inter-VLAN routing, enables devices in
separate VLANs to communicate through the router. Each VLAN will be assigned a
unique sub-interface with a corresponding IP address to act as the default gateway
for that VLAN.
2.2.1 Configure Sub-Interface for VLAN 2
Step 1: Create Sub-Interface GigabitEthernet 0/0.2:
Router# enable
Router# configure terminal
Router(config)# interface GigabitEthernet 0/0.2
Step 2: Set VLAN Encapsulation for VLAN 2:
Router(config-subif)# encapsulation dot1Q 2
Step 3: Assign IP Address to VLAN 2 Sub-Interface:
Router(config-subif)# ip address 192.168.2.1
255.255.255.0
Step 4: Enable the Sub-Interface:
Router(config-subif)# no shutdown
Router(config-subif)# exit
2.2.2 Configure Sub-Interface for VLAN 3
Step 1: Create Sub-Interface GigabitEthernet 0/0.3:
Router(config)# interface GigabitEthernet 0/0.3
Step 2: Set VLAN Encapsulation for VLAN 3:
Router(config-subif)# encapsulation dot1Q 3
Step 3: Assign IP Address to VLAN 3 Sub-Interface:
Router(config-subif)# ip address 192.168.3.1
255.255.255.0
Step 4: Enable the Sub-Interface:
Router(config-subif)# no shutdown
Router(config-subif)# exit
2.2.3 Configure Sub-Interface for VLAN 4(DHCP VLAN)
Step 1: Create Sub-Interface GigabitEthernet 0/0.4:
Router(config)# interface GigabitEthernet 0/0.4
Step 2: Set VLAN Encapsulation for VLAN 4:
Router(config-subif)# encapsulation dot1Q 4
Step 3: Assign IP Address to VLAN 4 Sub-Interface:
Router(config-subif)# ip address 192.168.4.1
255.255.255.0
Step 4: Enable the Sub-Interface:
Router(config-subif)# no shutdown
Router(config-subif)# exit
2.2.4 Enable Physical Interface GigabitEthernet 0/0
Step 1: Enter Interface Configuration Mode:
Router(config)# interface GigabitEthernet 0/0
Step 2: Bring the Physical Interface UP:
Router(config-if)# no shutdown
2.2.5 Save Configurations
Router# write memory
2.3 Configure DHCP Server
2.3.1 Assign IP Address to the Server
Configure a static IP address for the server, which will act as the DHCP server for
VLANs 2 and 3.
IP Address: 192.168.4.2
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.4.1
2.3.2 Configure DHCP for VLAN2
Create a DHCP pool on the server to allocate IP addresses to clients in VLAN 2.
Step 1: Open the DHCP configuration settings on the server.
Step 2: Create a new DHCP pool named DHCP-VLAN2 and configure the following:
Network Address: 192.168.2.0
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.2.1
DNS Server: 8.8.8.8
Step 3: Click Add.
2.3.2 Configure DHCP for VLAN2
Create a DHCP pool on the server to allocate IP addresses to clients in VLAN 3.
Step 1: Open the DHCP configuration settings on the server.
Step 2: Create a new DHCP pool named DHCP-VLAN3 and configure the following:
Network Address: 192.168.3.0
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.3.1
DNS Server: 8.8.8.8
Step 3: Click Add.
2.4 DHCP Relay Configuration
Since the DHCP server is located in VLAN 4, we must configure DHCP Relay on the
router to forward DHCP requests from VLANs 2 and 3 to the DHCP server.
2.4.1 Configure DHCP for VLAN 2
Step 1: Enter configuration mode for VLAN 2’s sub-interface:
Router(config)# interface GigabitEthernet 0/0.2
Step 2: Configure the IP helper address to forward DHCP requests to the server in
VLAN 4:
Router(config-subif)#ip helper-address 192.168.4.2
2.4.2 Configure DHCP for VLAN 3
Step 1: Enter configuration mode for VLAN 3’s sub-interface:
Router(config)# interface GigabitEthernet 0/0.3
Step 2: Configure the IP helper address to forward DHCP requests to the server in
VLAN 4:
Router(config-subif)#ip helper-address 192.168.4.2
2.5 Configuration IP Addresses on PCs.
Step 1: Open PC3->Desktop->IP Configuration.
Step 2: Click DHCP from Static. If DHCP IP Address is incorrect, just click Static,
then again DHCP.
Step 3: Repeat for other PCs.
2.6 Test Connectivity
Ping PC between each other. All PCs have to ping each other.
Part 3: Additional Task - Add new VLAN
3.1 Task Description
In this task, you will extend the existing network topology by adding a new VLAN
(VLAN 5) and integrating it with the current setup. Add 2 PCs to the switch which
ports FastEthernet0/7-8.
3.2 Steps to Complete the Task
1. Add to the last topology two PCs. They will be in VLAN 5.
2. In the Switch create VLAN 5 and assign it to port FastEthernet 0/7-8.
3. In the Router create a sub-interface GigabitEthernet 0/0.5 with VLAN encapsulation
dot1Q 5.Then assign IP address 192.168.5.1/24 to the sub-interface.
4. DHCP Configuration in the Server. Set up a DHCP pool for VLAN 5.
5. If the DHCP server is in VLAN 4, configure ip helper-address 192.168.4.2
on the sub-interface for VLAN 5.
6. Verify that devices in VLAN 5 receive IP addresses via DHCP and can communicate
with other VLANs.