If you receive command not found
when trying to run dhcp
or dhclient
, it's possible that these are not installed.
To install the DHCP client utilities run:
sudo apt install isc-dhcp-client
This will install the isc-dhcp-client
package, which includes the dhclient.
After the installation, you should be able to use the dhclient
command to receive an IP address from a DHCP server.
Make sure that /etc/network/interfaces
is configured to use DHCP.
auto eth0
iface eth0 inet dhcp
Replace eth0
with your network interface name on your system.
Restart the networking with:
systemctl restart networking
You can run the following command to request an IP address:
sudo dhclient
The dhcpd
command you mentioned is for the DHCP server, not the client.
If you need to configure and run a DHCP server, you will need to install and set up the isc-dhcp-server
package instead.
Configure network with netplan:
How to Configure Networking in Ubuntu 20.04 with NetPlan
Locate the netplan
configuration file in the /etc/netplan/
folder
and has a .yaml
extension.
Edit the file, should see a yaml
structure defining the network interfaces and their configurations. Set the dhcp4
property to true
.
nano /etc/netplan/YOUR_NETPLAN_CONFIG_FILE.yaml
dhcp example:
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: true
dhcp6: true
If you have multiple network interfaces, you can add similar sections for each interface.
Apply changes:
netplan apply
Request an IP address:
sudo dhclient
Ubuntu source:
Ubuntu Network configuration
/etc/network/interfaces
file.if-pre-up.d
andif-up.d
folders there