DHCPCD

Dynamic Host Configuration Protocol Client Daemon is a popular DHCP client capable of handling both IPv4 and IPv6 configuration 0.

Dynamic IP configuration

Begin by first verifying that you have dhcpcd installed:

$ kiss b dhcpcd
$ kiss i dhcpcd

Once installed, dhcpcd can be used to automatically configure a network device interface:

$ dhcpcd INTERFACE

Remember to replace INTERFACE in the command above with the name of the device that you wish to configure.

A network device’s interface status can be inspected via ip-link:

$ ip link show dev INTERFACE

ip-link can also be used to enable or disable an interface:

$ ip link set INTERFACE down  # disable the interface
$ ip link set INTERFACE up    # enable  the interface

Static IP configuration

Continuing from the previous section, we can use ip-address to display the current DHCP address information:

$ ip address show

Using the output of the previous command, add the following lines to the /etc/dhcpcd.conf file using your preferred text editor:

interface INTERFACE
static ip_address=STATIC_IP
static routers=GATEWAY
static domain_name_servers=DNS_SERVER

Remember to replace the INTERFACE, STATIC_IP, GATEWAY and DNS_SERVER in the block above with your own parameters.

Hostname

A system’s hostname can be set by simply creating a /etc/hostname file:

$ echo "HOSTNAME" > /etc/hostname

Remember to replace HOSTNAME with the string of your choosing.

NOTE: Valid characters for hostnames include ASCII letters from A to Z, digits from 0 to 9, and the hyphen character (-). A hostname may not start with a hyphen.

Managed via runsv

Busybox’s runsv can be used to create a new managed service with the following command:

$ ln -s /etc/sv/dhcpcd/ /var/service

To start the new managed service, use the following command:

$ sv up dhcpcd

Tips and Tricks