Client
Configuration
Create a basic /etc/dhcp/dhclient.conf
by running the
following command as the root
user:
install -vdm755 /etc/dhcp &&
cat > /etc/dhcp/dhclient.conf << "EOF"
# Begin /etc/dhcp/dhclient.conf
#
# Basic dhclient.conf(5)
#prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
netbios-name-servers, netbios-scope, interface-mtu,
ntp-servers;
require subnet-mask, domain-name-servers;
#timeout 60;
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;
# End /etc/dhcp/dhclient.conf
EOF
See man 5
dhclient.conf for additional options.
Now create the /var/lib/dhclient
directory which will contain DHCP Client leases by running the
following command as the root
user:
install -v -dm 755 /var/lib/dhclient
At this point you can test if dhclient is behaving as
expected by running the following command as the root
user:
dhclient <eth0>
Replace <eth0>
with your desired interface. If you want more verbose output, add
the -v parameter to
the command above.
If you want
to configure network interfaces at boot using dhclient, you need to install
the /lib/services/dhclient
script
included in blfs-bootscripts-20180105 package:
make install-service-dhclient
Next,
create the /etc/sysconfig/ifconfig.eth0
configuration file
with the following commands as the root
user:
cat > /etc/sysconfig/ifconfig.eth0 << "EOF"
ONBOOT="yes"
IFACE="eth0"
SERVICE="dhclient"
DHCP_START=""
DHCP_STOP=""
# Set PRINTIP="yes" to have the script print
# the DHCP assigned IP address
PRINTIP="no"
# Set PRINTALL="yes" to print the DHCP assigned values for
# IP, SM, DG, and 1st NS. This requires PRINTIP="yes".
PRINTALL="no"
EOF
Adjust the file to suit your needs.
For more information on the appropriate DHCP_START
and DHCP_STOP
values see man 8 dhclient.
Server Configuration
Note that you only need the DHCP server if you want to issue LAN
addresses over your network. The DHCP client doesn't need the
server in order to function properly.
Start with creating /etc/dhcp/dhcpd.conf
by running the following
command as the root
user:
cat > /etc/dhcp/dhcpd.conf << "EOF"
# Begin /etc/dhcp/dhcpd.conf
#
# Example dhcpd.conf(5)
# Use this to enble / disable dynamic dns updates globally.
ddns-update-style none;
# option definitions common to all supported networks...
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;
default-lease-time 600;
max-lease-time 7200;
# This is a very basic subnet declaration.
subnet 10.254.239.0 netmask 255.255.255.224 {
range 10.254.239.10 10.254.239.20;
option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org;
}
# End /etc/dhcp/dhcpd.conf
EOF
Adjust the file to suit your needs. See man 5 dhcpd.conf for additional
options.
Now create the /var/lib/dhcpd
directory which will contain DHCP Server leases by running the
following command as the root
user:
install -v -dm 755 /var/lib/dhcpd
If you want to start the DHCP Server at boot, install the
/etc/rc.d/init.d/dhcpd
inti
script included in the blfs-bootscripts-20180105 package:
make install-dhcpd
You will need to edit the /etc/sysconfig/dhcpd
in order to set the
interface on which dhcpd will serve the DHCP
requests.