5

I'm working on a custom Ubuntu 20.04 server and am trying to get a dhcp IP for it. The server has so far run on a static IP and when I run dhcp or dhclient it says dhcpd: command not found and dhclient: command not found.

The /sbin has no dhcpd or dhclient directories but there is a /etc/dhcp folder which contains dhclient-enter-hooks.d dhclient-exit-hooks.d with scripts in it to which I assume is start/stop dhcp.

What I want to know is if it's possible that dhcp or dhclient is not installed in this machine or if I'm missing the installation path and if it isn't which should be the best one to install to get a dhcp IP from.

6
  • 2
    It's possible that it just wasn't installed by those who set up the machine originally. If they are still available you might ask them. If not, you might want to ask the package system whether those packages are installed. It will certainly know better than anyone else. On top of that, it will be super helpful in installing the packages if indeed they aren't installed yet. Commented May 30, 2023 at 9:44
  • 4
    Can you post your /etc/network/interfaces file. Commented May 30, 2023 at 10:23
  • @Hans-MartinMosner checked in installed packages, doesn't look like they're installed. Commented May 30, 2023 at 10:31
  • @BlockchainOffice, ther is no interfaces file only if-pre-up.d and if-up.d folders there Commented May 30, 2023 at 10:32
  • 4
    Do you got /etc/netplan/FILENAME.yaml ? Commented May 30, 2023 at 10:36

2 Answers 2

7

If you receive command not found when trying to run dhcp or dhclient, it's possible that these are not installed.

The dhcpd command you mentioned is for the DHCP server, not the client.

To install the DHCP client utilities run:

As @John Greene already mentioned in his post, ISC announced the end of maintenance for ISC DHCP (isc-dhcp-client).

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.

Other alternative clients for Debian and/or Ubuntu

Alternative DHCP_Client | Debian Wiki

  • The list comes from the Debian Wiki, and one should ensure to find the corresponding packages for Ubuntu!

  • You should not simply install Debian packages on Ubuntu (or vice versa) because the two systems have different versions of libraries and dependencies, which can lead to incompatibilities and system errors.

  • Additionally, the deep integration of packages into the system (e.g., services or configurations) can cause issues if they are not specifically designed for the respective distribution!

Here is a set of DHCP clients that might work as an alternative from the Debian Wiki:

systemd-networkd

systemd-networkd is a system daemon that manages network configurations. It detects and configures network devices as they appear, it can also create virtual network devices.

udhcpc

udhcpc is a very small DHCP client program geared towards embedded systems.The letters are an abbreviation for Micro - DHCP - Client (μDHCPc).The program tries to be fully functional and RFC 2131 compliant.

dhcpcd

dhcpcd is a DHCP and DHCPv6 client. It is currently the most feature-rich open source DHCP client; see the home page for the full list of features.

dhcpcanon

dhcpcanon is a DCHP client implementation of the DHCP Anonymity Profiles (RFC7844). using Scapy Automaton.

NetworkManager

By default NetworkManager uses its internal DHCP client. The internal DHCPv4 plugin is based on the nettools' n-dhcp4 library, while the internal DHCPv6 plugin is made from code based on systemd-networkd.

odhcp6c

odhcp6c is a minimal DHCPv6 and RA-client for use in embedded Linux systems especially routers. It compiles to only about 35 KB (-Os -s).

coredhcp client

Coredhcp is a fast, multithreaded, modular and extensible DHCP server written in Go. In CoreDHCP almost everything is implemented as a plugin. Every request is evaluated calling each plugin in order, until one breaks the evaluation and responds to, or drops, the request.

Configure DHCP over /etc/network/interfaces

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

DHCP server

For resources that may help in migrating your existing ISC DHCP server deployment to our newer DHCP server, Kea. ISC DHCP

Migrating to Kea from ISC DHCP

Kea is the DHCP server developed by ISC to replace isc-dhcp. It is newer and designed for more modern network environment

How to install and configure isc-kea on ubuntu

Old isc-dhcp-server

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:

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:

Debian source:

Network configuration:

1
  • 1
    thanks, didn't know that dhcpd was for the server Commented May 30, 2023 at 10:57
2

Vendor for DHCP client has changed as ISC no longer maintains dhclient.

apt remove isc-dhcp-client 

The new Ubuntu/Debian package name for dhcpcd is dhcp-client.

apt install dhcp-client 

What The Change?

After the version 23.01+ of Ubuntu, dhclient will no longer be available because ISC has end-of-life'd (EOL) the client part of dhcp (dhclient)(in Ubuntu bug #2024164). Package name was isc-dhcp-client.

There are many DHCP client alternatives.

The only two viable alternatives are: dhcpcd for desktop/server and udhcpc for embedded system/IoT.

These alternative DHCP clients are based on following requirements:

  1. The DHCP client must support DHCPv6.
  2. The DHCP client in the initramfs should be small enough to not increase the size noticeable.
  3. The DHCP client needs to be callable from the shell (for initramfs and cloud-init)

Neither systemd-networkd nor ifconfig support DHCP client over IPv6. And systemd-networkd is a daemon-only, not CLI-based needed to execute the diverse script-based site-specific customization (nameserver, NTP, WINS, and notably systemd).

Note: Redhat no longer provides dhcpcd since 2019 that is found in most other Linux distros. Redhat provides the (obsoleted) ISC dhclient instead.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.