|/
|\ISS

*ARCHIVED*
OFFICIAL SITE

News
Blog

Wiki

Install KISS
FAQ

Package System
Package Manager
Software

Guidestones

Testimonials
Screenshots
Team

Contact
Donate
Website
IRC

GitHub
Git (mirror)
ML (archive)



wiki / software / dhcpcd                                          Edit this page

Edited (1aca415) at 2020-06-10 by Dylan Araps


DHCPCD [0]
________________________________________________________________________________

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


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
________________________________________________________________________________

* A list of possible INTERFACE names can be obtained by running the following:

  +----------------------------------------------------------------------------+
  |                                                                            |
  |   $ ls /sys/class/net                                                      |
  |                                                                            |
  +----------------------------------------------------------------------------+

* The ping command can be used to verify connectivity with a network device
  interface:

  +----------------------------------------------------------------------------+
  |                                                                            |
  |   $ ping www.google.com                                                    |
  |                                                                            |
  +----------------------------------------------------------------------------+

* Some network administrators require that the hostname and domain name provided
  by the DHCP server is used by the system. In that case, pass the "-HD" switch:

  +----------------------------------------------------------------------------+
  |                                                                            |
  |   $ dhcpcd -HD INTERFACE                                                   |
  |                                                                            |
  +----------------------------------------------------------------------------+

* If you are not sure what to put in the STATIC_IP, GATEWAY and DNS_SERVER, you
  can use the following example for reference:

  +----------------------------------------------------------------------------+
  |                                                                            |
  |   interface eth0                                                           |
  |   static ip_address=192.168.0.4/24                                         |
  |   static routers=192.168.0.1                                               |
  |   static domain_name_servers=192.168.0.1                                   |
  |                                                                            |
  +----------------------------------------------------------------------------+

  Notice the "/24" suffix, which is an abbreviation for the subnet mask
  255.255.255.0. Also, GATEWAY and DNS_SERVER are the same in this example.


References
________________________________________________________________________________

[0] https://github.com/rsmarples/dhcpcd
[1] https://wiki.archlinux.org/index.php/Network_configuration
[2] https://wiki.gentoo.org/wiki/Dhcpcd


________________________________________________________________________________

This site is an archive of a previous version of KISS's website. The current
version can be found at https://kisslinux.org/.

Dylan Araps    (C) 2019-2020
kiss-community (C) 2020-2021
Dilyn Corner   (C) 2021

Linux(R) is the registered trademark of Linus Torvalds in the U.S. and
other countries.