Lab 4a: Configuring a

DHCP client

Objective

  1. Configure a Linux machine as a DHCP client

  2. Configure a Windows machine as a DHCP client

Background Information

VMware is setup to provide a DHCP service to client VMs when enabled.

Our configuration has a virtual DHCP server for network VMnet8, the default NAT interface.

This DHCP server will assign IP addresses in the range 192.168.3.128 – 192.168.3.254 inclusive to the lab room (it may be different if at home).

But for other machines and other interfaces (like our VMnet2 network), we may need to know how to configure DHCP client workstations. We will also need this in later Lab 4 activities.

Also note that a lot of internet documentation about Linux DHCP refers to a separate ‘dhclient’ program. When using NetworkManager (as we are), there is no need to run dhclient separately.

NetworkManager has DHCP support built in.

Task 1: Linux command-line configuration

Test the network connectivity using

ping and ssh.

Check the machine’s IP address with ifconfig or nmcli.


Verify and/or change the configuration

Verify and/or change the configuration files so that when your machine boots, it will automatically send a DHCP query to retrieve network settings. The most important change is to change BOOTPROTO from "none" to "dhcp" in the interface-specific configuration file in /etc/sysconfig/network-scripts/ifcfg-ens* (where ens* is your specific adapter eg: ens37).

In addition to the above change, also comment out the other lines manually in both the ifcfg-ens* file, and the line that sets the interface as the default gateway.

set the IP address,

netmask, etc.

The comment character is a # (same as a UNIX shell script).

Reboot the Linux virtual machine and test that the network is up and that the IP address appears to have been dynamically allocated. Test network connectivity using ping and ssh.

Alternatively we could just ifdown and ifup, but rebooting ensures all caches, etc are cleared. But on a production server we wouldn’t normally reboot for testing!

Note: from previous lab exercises where we installed software updates, we might have already configured the machine as a DHCP client without even knowing it. So if the above description seems like it already matches what is on your system, just verify it and make sure you understand what’s happening (and make notes in your journal).

Task 2: Linux GUI configuration

We can also configure this via the Settings icon → Network menu item,

or running either

gnome-control-center or

nm-connection-editor

Choose the appropriate adapter, and then Click the properties to change this. Choose the appropriate tab to change the

configuration (usually IPv4 settings for DHCP).

HINT: If we haven't already done so, we can also take this time to make ens37 connect automatically so we don't have to keep clicking the network manager icon to start the network connection!

Task 3: Windows configuration

On Windows Server, you use the GUI to do most configuration, although it is useful to know the command-line versions to create scripts to automate management of servers (or client workstations).

  1. From Server Manager, choose Server Manager → View Network Connections (alternative: Start → Admin Tools → Settings → Control Panel → Network and Sharing centre → Manage Network Connections

  2. Choose the appropriate adapter & select Properties

  3. In the Items listing, choose Internet Protocol v4 (TCPIP IPV4) and choose Properties

  4. Set the “Obtain an IP address automatically” radio button

You can also investigate how to do this from the command line. You need to use the following command

netsh