Using DHCP on the Agent

Overview

When configuring your Agent, you may want to use DHCP to manage your Agent's IP address configuration.

To accomplish this, the menu script comes pre-built with options to make this configuration process simple and easy. However, the instructions below include two methods to set up DHCP using two different ways.

Prerequisites: Identify your network interface card

Depending on your configuration, your interface name may be different than some of the common names, such as eth0, ens33, etc. Prior to setting your IP address information, you'll want to gather the interface name that you would like to set the IP address for.

To identify which network interfaces you have, run the ifconfig command from the terminal prompt. You should see the following output:

In the above example, the primary interface is ens33. This is the network interface that we'll be using throughout the rest of this tutorial.

Configuring DHCP using the menu

  1. Load up the menu Agent (if it's not already loaded) by typing one of the following commands:
    • vtp
    • /root/vpentest.rb

    You should see the following screen after typing one of the aforementioned commands:

  2. Choose option 1.
  3. After choosing option 1 on the next screen, you will see the following screen:

  4. Choose option 2.
  5. On the screen displayed in the previous step, you'll want to choose option 2. After choosing option 2 to assign a DHCP configuration, you will be prompted to choose a network interface adapter, as shown below:

    When prompted to select a network interface, select the network interface adapter that you identified in the prerequisites step.

Configuring DHCP using netplan

If you prefer to set up DHCP outside of the Agent's menu, you can use the netplan command. To learn more about netplan and other configurations , please visit the following URL: https://netplan.io.

To configure your system to use DHCP, perform the following steps:

  1. Copy a "dhcp IP address YAML template."
  2. Run the following command from the command line interface:

    cp /usr/share/doc/netplan/examples/dhcp.yaml /etc/netplan/dhcp.yaml
  3. Edit the "dhcp IP address YAML template."
  4. Next, you will want to use a text editor, such as nano, vim, etc. In the example below, we're using the vim text editor. To use nano, for example, you can run the following command:

    nano /etc/netplan/dhcp.yaml

    Using vim, you would run the following command:

    vim /etc/netplan/dhcp.yaml

    Once you've got a text editor opened, your output should look very similar to this:

    Using your text editor, you'll want to replace the line that shows enp3s0 (the default network interface) to whatever interface you would like to configure DHCP on.

    Once you've modified the file and saved your changes, you can apply the configuration using the following command:

    netplan apply