Lab 04 ‐ DHCP - Isaiah-River/SYS-255-02-SYSAdmin GitHub Wiki

The goal of this lab is to get our DHCP virtual machine set up and running DHCP services, and configuring our WKS virtual machine to automatically obtain its IP through our DHCP server. I began by remote accessing into my DHCP virtual machine with my AD virtual machine. After this I used the command sudo yum install dhcp to install DHCP on the server. I then used the command sudo -i to become the system user, and then used vi /etc/dhcp/dhcpd.conf to open the DHCP configuration with vim. After this I configured the configuration file as seen below.

image

I then used the command :wq to save and quit vim. I then use the command systemctl start dhcpd to start my DHCP service, and then used the command systemctl status dhcpd in order to check the status.

image

I then used the command systemctl enable dhcpd in order to allow DHCP to run on bootup.

image

After this I needed to configure my firewall in order to allow incoming DHCP requests. The command firewall-cmd --list-all shows the configuration for the firewall.

image

I then used the command firewall-cmd --add-service=dhcp --permanent to permanently add DHCP to the services allowed through firewall. I then used firewall-cmd --reload to refresh my firewall. After this I checked the configuration of the firewall to see that I've added DHCP to the services.

image

Now that I've installed, configured, and allowed DHCP through the firewall, I went to WKS virtual machine, and set my IPv4 configuration to use dynamic addressing.

image

After adjusting to dynamic addressing, I used ipconfig /all on my WKS virtual machine to determine that my DHCP settings have worked. As you can see below the IP is set to the first one included in my range from my earlier configuration, as well as the inclusion of the DHCP server address.

image

After this I find the DHCP log that is associated with WKS request for DHCP information by remote connecting back into DHCP and using the command sudo cat /var/log/messages | grep wks01-isaiah to search for information that includes my wks01 virtual machine.

image

After this I went to my WKS virtual machine, and started a Wireshark capture in order to try to get a capture of the 4 key DHCP messages. After starting the capture I used the commands ipconfig /release, then I used the command ipconfig /renew and finally used the command ipconfig /all.

image

I then stopped my Wireshark capture, and used the filter udp.port==67 to find packets that use the port for the DHCP server.

image

After this I went back into my configuration files for my DHCP server, and added the lines:

   default-lease-time 3600; 

   max-lease-time 14400;

image

I then went and restarted my DHCP server.

image

After this I confirmed that this is working by resetting my lease using ipconfig /release and ip config /renew and finally ipconfig /all to see that my lease in fact expires after an hour.

image

I then did some looking into several other tech aspects of DHCP, and explored their contents in my earlier Wireshark capture.


Option Codes - Option codes are used by DHCP in order to configure additional information to devices. These options can include everything from the lease length, to the domain name, and more.

DHCP Message Type - Option (53) - The DHCP message type is essentially what stage of DHCP a certain "message" is at, whether its the release (which has a value of 7), discover (which has a value of 1), offer (which has a value of 2), request (which has a value of 3), or acknowledgement (which has a value of 6). This uses the option code 53. In the example below the message type is a offer.

image

Lease Duration - Option (51) - The lease duration is how long one of these assigned IP addresses will actually be leased out for. The option code for IP address lease duration is 51. In this example below the DHCP server offers a lease for 12 hours.

image

Subnet Mask - Option (1) - DHCP makes use of a subnet masks which define a network's address range, and define which part of an IP is the network and which is the host. The option code for the subnet mask is 1. In the example below 255.255.255.0 defines a class C subnet mask, where only the last octet are the hosts, while the first three are reserved for the network

image

Default Gateway - Option (3) - The default gateway IP is defined in DHCP so that devices are able to route traffic to the router, and outside of the local network. The option code for this is 3. In the example below the router address is assigned as 10.0.5.2.

image

DNS Configuration - Option (6) - The DNS server addresses can also be configured in DHCP which allows for devices to resolve domain names to IP addresses. The option code for this is 6. In the example the IP address for my DNS server is 10.0.5.5

image

Parameter Request List - Option (55) - The parameter request list is used by the DHCP client in order to request specific configuration parameters, or options, such as the one's listed above. The option code for this is 55. In the example below you can see the DHCP client requesting a whole range of various options.

image