DHCP/IPv4 Client Custom Config

Overview

Fix other systems (even before the damage is caused). Otherwise, problems can crop up. Even worse: if the problems (like an incorrect system being used for routing or name resolution) get fixed manually, the issue might be incorrectly diagnosed as an address being manually configured wrong. Instead, the incorrect address happened due to automation, and the actual issue may break things again when the DHCP server renews.

[#dhcmltnc]: Multi-NIC systems (DHCP issues)

This is commonly encountered if there is a firewall which may run DHCP on multiple NICs. Failure to address this can result in breaking communications for an entire network.

Perhaps a system wishes to get an IP address from a NIC. That is fine, but what is not fine is if the machine decides to start routing Internet-bound traffic through that same NIC.

(The process to take care of this will be described by: Fixing multi-NIC systems (DHCP issues).)

[#dhcnsvno]: DNS servers (DHCP issues)

Most systems may need to use settings that point to specific DNS servers, but internal DNS servers may handle DNS differently.

Samples

If there are systems that require custom handling, there may be some benefit to looking at a default configuration file. For example, here are some examples from OpenBSD:

$ echo send host-name \"$(hostname -s)\"\;| diff -s /etc/dhclient.conf -
Files /etc/dhclient.conf and - are identical
$ echo ${?}
0
$ cat /etc/examples/dhclient.conf
# $OpenBSD: dhclient.conf,v 1.1 2014/08/29 18:05:39 ajacoutot Exp $
#
# DHCP Client Configuration
#
# See dhclient.conf(5) for possible contents of this file.
# When empty default values are used:
#
# Example:
#
# send dhcp-lease-time 3600;
# send host-name "myhost";
# supersede host-name "myhost";
# supersede domain-name "my.domain";
# request subnet-mask, broadcast-address, time-offset, routers,
# domain-name, domain-name-servers, host-name, lpr-servers, ntp-servers;
# require subnet-mask, domain-name-servers, routers;
$
  • (A couple of hyperlinks are included in that sample output.)
  • The - parameter, given to the diff command, is a way to specify “standard input”. This technique is supported by many standard Unix programs.
Fixing issues
[#dhcfxmln]: Fixing multi-NIC systems (DHCP issues)

This ought to take care of the concern mentioned by the overview section on Multi-NIC systems (DHCP issues).

These instructions will show how to make the appropriate /etc/hostname.* file use an alternate configuration file (like dhclnort.cnf (DHCP client: no route) instead of dhclient.conf)

This first part likely requires no manual customization. It contains a system host name, so this should be run separately on each system that this is done on:

[ -f /etc/dhclnort.cnf ] && cpytobak /etc/dhclnort.cnf
echo send dhcp-lease-time 3600\;| sudo -n tee -a /etc/dhclnort.cnf
echo send host-name \"$(hostname -s)\"\;| sudo -n tee -a /etc/dhclnort.cnf
echo \# supersede host-name \"$(hostname -s)\"\;| sudo -n tee -a /etc/dhclnort.cnf
echo \# supersede domain-name \"my.domain\"\; \# correct this if used: should be non-host part of \"$(hostname)\"\; | sudo -n tee -a /etc/dhclnort.cnf
echo request subnet-mask, broadcast-address, time-offset,| sudo -n tee -a /etc/dhclnort.cnf
echo \\tdomain-name, domain-name-servers, host-name, lpr-servers, ntp-servers\;| sudo -n tee -a /etc/dhclnort.cnf
echo require subnet-mask, domain-name-servers\;| sudo -n tee -a /etc/dhclnort.cnf
echo ignore routers, host-name\;| sudo -n tee -a /etc/dhclnort.cnf
  • This example assumes that echo converts \t to a tab.
  • You may wish to modify the file to clean-up the comment about the domain-name. However, since it is just a comment, that is not technically necessary for functionality. (The comment, as shown, is a bit vague/unclear. The desired value for the supersede domain-name line does NOT start with a period. So if the computer is named system.example.zz then the desired value would be "example.zz".)

There, got all that? Now...

  • This next part should be done a bit more carefully...
    • Differences may exist between different operating systems.
    • There may be a need to customize the name of the NIC.
cpytobak /etc/hostname.em1
echo !dhclient -c /etc/dhclnort.cnf -i routers,host-name \${if}| sudo -n tee -a /etc/hostname.em1
echo ${VISUAL}
sudoedit /etc/hostname.em1
  • This placed the desired line at the end of the file. However, the line may be better to place earlier in the file. Replace any existing line that only contains the word dhcp. (A review of the entire file may be quite sensible to perform, at this time.)
  • This example is assuming that /etc/netstart will define the ${if} variable appropriately (which happens in OpenBSD). (So don't worry if that variable doesn't seem to actively defined for a standard command prompt.)
[#dhcfxnsv]: Fixing DNS servers (DHCP issues)

This ought to take care of the concern mentioned by the overview section on DNS servers (DHCP issues).

These instructions will show how to make the appropriate /etc/hostname.* file use an alternate configuration file (like dhclndns.cnf (DHCP client: no DNS) instead of dhclient.conf)

This first part likely requires no manual customization. It contains a system host name, so this should be run separately on each system that this is done on:

[ -f /etc/dhclndns.cnf ] && cpytobak /etc/dhclndns.cnf
echo send dhcp-lease-time 3600\;| sudo -n tee -a /etc/dhclndns.cnf
echo send host-name \"$(hostname -s)\"\;| sudo -n tee -a /etc/dhclndns.cnf
echo \# supersede host-name \"$(hostname -s)\"\;| sudo -n tee -a /etc/dhclndns.cnf
echo \# supersede domain-name \"my.domain\"\; \# correct this if used: should be non-host part of \"$(hostname)\"\; | sudo -n tee -a /etc/dhclndns.cnf
echo request subnet-mask, broadcast-address, time-offset, routers,| sudo -n tee -a /etc/dhclndns.cnf
echo \\tdomain-name, host-name, lpr-servers, ntp-servers\;| sudo -n tee -a /etc/dhclndns.cnf
echo require subnet-mask, routers\;| sudo -n tee -a /etc/dhclndns.cnf
echo ignore domain-name-servers, host-name\;| sudo -n tee -a /etc/dhclndns.cnf
  • This example assumes that echo converts \t to a tab.
  • You may wish to modify the file to clean-up the comment about the domain-name. However, since it is just a comment, that is not technically necessary for functionality. (The comment, as shown, is a bit vague/unclear. The desired value for the supersede domain-name line does NOT start with a period. So if the computer is named system.example.zz then the desired value would be "example.zz".)

There, got all that? Now...

  • This next part should be done a bit more carefully...
    • Differences may exist between different operating systems.
    • There may be a need to customize the name of the NIC.
cpytobak /etc/hostname.em0
echo !dhclient -c /etc/dhclndns.cnf -i domain-name-servers,host-name \${if}| sudo -n tee -a /etc/hostname.em0
echo ${VISUAL}
sudoedit /etc/hostname.em0
  • This placed the desired line at the end of the file. However, the line may be better to place earlier in the file. Replace any existing line that only contains the word dhcp. (A review of the entire file may be quite sensible to perform, at this time.)
  • This example is assuming that /etc/netstart will define the ${if} variable appropriately (which happens in OpenBSD). (So don't worry if that variable doesn't seem to actively defined for a standard command prompt.)