Lab #4

Two hosts and a DHCP server

The purpose of this lab is to show how IP addresses can be assigned to end-systems by means of a DHCP server.

NOTICE: this lab requires the GNS3 VM to instantiate a Docker container of a Linux-based DHCP server.

Preparation steps

The procedure described here will be executed only once. Its purpose is to give GNS3 the ability to instantiate a Docker container of a Linux-based DHCP server. This component will be also used in further labs. This preparation step, however, will not be repeated.
  1. In GNS3 go to Edit/Preferences... and select Docker container templates from the panel on the left of the Preferences window.
  2. Click on New.
  3. Select the Run this Docker container on the GNS3 VM option and press Next.
  4. Choose the New image action.
  5. Type rcanonico/alpine-dhcp-server:latest in the Image name textbox and press Next.
  6. Change the template name in dhcp-nat and press Next.
  7. Specify 2 as the number of adapters you want this container to use and click Next.
  8. Specify /bin/sh as the Start command textbox and click Next.
  9. Leave the console type set to telnet and click Next.
  10. Specify the following environment variables in the Environment textbox and click Next.
  11. ETH0_IP=192.168.30.1
    ETH0_SUBNET=192.168.30.0
    ETH0_NETMASK=255.255.255.0
    LAN_IFACE=eth0
    WAN_IFACE=eth1
    
  12. Click Finish to complete this configuration process. dhcp-nat will now appear in the list of available Docker container templates.
  13. In the Preferences window, select dhcp-nat from the list of available Docker container templates and click Edit.
  14. In the Docker container template configuration window that appears, choose the Routers category.
  15. In the same window, choose the Browse... button, select the router symbol from the Classic set of icons and press OK.
  16. Press OK to close the Docker container template configuration window.
Notice that the first time that the dhcp-nat component will be added to a GNS3 project, the Docker container image will be pulled from Docker Hub repository. This will require a few seconds.

Experiment steps

  1. Recreate the following topology in GNS3. Choose the "GNS3 VM" server to instantiate all the devices of this lab.
  2. lab8-topology
  3. When the devices are still inactive, right-click on the dhcp-nat-1 icon and select the Configure option.
  4. Press Edit to modify the router's network configuration.
  5. Modify the router's interfaces configuration as illustrated in the following picture.

  6. router-configuration
     
  7. Start all devices.
  8. Open dhcp-nat-1 terminal and execute the start.sh script with the command:
  9. ./start.sh
  10. Start capture on link connecting Switch1 to dhcp-nat-1.
  11. Open PC1 terminal and execute the following command to configure PC1's NIC with an IP address obtained via DHCP:
  12. ip dhcp
    A sequence of DHCP messages (Discover, Offer, Request, Ack) is exchanged between PC1 and the DHCP server until an IP address (e.g. 192.168.30.6) is assigned to PC1.

    lab8-pc1-dhcp
  13. Open PC2 terminal and execute the following command to configure PC2's NIC with an IP address obtained via DHCP:
  14. ip dhcp
    A sequence of DHCP messages (Discover, Offer, Request, Ack) is exchanged between PC2 and the DHCP server until an IP address (e.g. 192.168.30.7) is assigned to PC2.

    lab8-pc2-dhcp
  15. In PC1 terminal execute the command to ping PC2:
    ping 192.168.30.7
    and verify that answers are received.
  16. lab8-pc1-ping-pc2

Packet capture analysis

The picture below shows the packets captured by Wireshark running on the link connecting Switch1 to dhcp-nat-1 during DHCP sequence.

lab8-wireshark


Return to list of labs

Copyright (c) 2024 - Roberto Canonico

Last updated: October 3, 2024 by Roberto Canonico