4

What are the valid values (and what are they used for) for the static option in /etc/dhcpcd.conf file?

I'm configuring a network interface of a Raspberry (running raspbian stretch) by editing the /etc/dhcpcd.conf file.
Altough I was able to set up it correctly, I am curious about all the configuration options provided through this file, specifically for static configuration.

I read the man page of dhcpcd.conf and didn't find any explanation of the values the static option accepts. I wasn't able to find anything on google neither.

The man page of dhcpcd.conf just says this:

 static value
         Configures a static value.  If you set ip_address then dhcpcd
         will not attempt to obtain a lease and will just use the value
         for the address with an infinite lease time.  If you set
         ip6_address, dhcpcd will continue auto-configuation as normal.

         Here is an example which configures two static address,
         overriding the default IPv4 broadcast address, an IPv4 router,
         DNS and disables IPv6 auto-configuration.  You could also use the
         inform6 command here if you wished to obtain more information via
         DHCPv6.  For IPv4, you should use the inform ipaddress option
         instead of setting a static address.
               interface eth0
               noipv6rs
               static ip_address=192.168.0.10/24
               static broadcast_address=192.168.0.63
               static ip6_address=fd51:42f8:caae:d92e::ff/64
               static routers=192.168.0.1
               static domain_name_servers=192.168.0.1
               fd51:42f8:caae:d92e::1

         Here is an example for PPP which gives the destination a default
         route.  It uses the special destination keyword to insert the
         destination address into the value.
               interface ppp0
               static ip_address=
               destination routers

After reading some tutorials all valid options I know are these:

  • ip_address

  • routers

  • domain_name_servers

  • domain_search

  • domain_name


JFYI my /etc/dhcpcd.conf configuration file looks like this:

# Inform the DHCP server of our hostname for DDNS.
hostname
# Use the hardware address of the interface for the Client ID.
clientid
# Persist interface configuration when dhcpcd exits.
persistent
# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit
# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# A ServerID is required by RFC2131.
require dhcp_server_identifier
# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private
# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname

# Static IP configuration for eth0.
interface eth0
    static ip_address=192.168.12.234/24
    static routers=192.168.12.1
    static domain_name_servers=192.168.12.1
    nogateway
migrc
  • 503
  • 4
  • 15
  • 1
    I don't mean to be condescending but do you not have an understanding of basic networking? The values for each of those options are just a basic ip address/subnet mask, broadcast, DNS server, and the static router is the default gateway. – Nasir Riley Jul 05 '19 at 10:41
  • No, I understand their meaning and what they do (and even make use of them), but didn't find any documentation apart from tutorials. I'm looking for a more "official" manual that explain what are the values accepted for the static option, what they do, etc. because I don't know if those are the only valid options (those are just the ones present in some tutorials I read) or there are more. – migrc Jul 05 '19 at 11:00
  • 1
    As long as the syntax that you have follows what you see in that example then that's what's accepted. Whether or not you actually get a network connection depends on whether or not the values match up with the settings in your network such as the default router, network range, DNS, etc. – Nasir Riley Jul 05 '19 at 11:08
  • My problem is not about correctness of the configuration. It's curiosity more than anything else. – migrc Jul 05 '19 at 11:16

1 Answers1

1

I was wondering the same thing and also couldn't find any definitive answers out there, so I went digging.

I don't know if this is an exhaustive list, but here is a list of valid values for the static option that I have been able to glean from looking at the source code (available here):

ip_address
subnet_mask
broadcast_address
routes
static_routes
classless_static_routes
ms_classless_static_routes
routers
interface_mtu
mtu
ip6_address

These parameters are directly handled in the if-options.c file.

Here is where I am less certain about it being exhaustive, and where I am getting a bit speculative on what is going on. As you have no doubt noticed, this doesn't include domain_name_servers, etc. After parsing the config file and directly dealing with any of the above parameters, there can still be some parameters that have not been handled in if-options.c. I think that these remaining parameters are dealt with in the default hook scripts, specifically the 20-resolv.conf hook script (/usr/lib/dhcpcd/dhcpcd-hooks), for which I think there are only the following options:

domain_name
domain_name_servers
domain_search

As I said, I'm a bit unsure about the last bit as I didn't want to spend crazy amounts of time going through the source code. So any corrections would be very welcome.