DNS, DHCP and NTP
Three small services make a network usable: something that answers
name lookups, something that hands out addresses, and something that keeps
the clock right. A desktop uses all three as a client; a machine that
serves a network runs the first two as a server.
Name resolution
The resolver reads /etc/resolv.conf. It lists
the name servers in the order they are tried, and the domain that
short names belong to:
search example.lan
nameserver 192.168.1.1
nameserver 9.9.9.9
/etc/nsswitch.conf decides where a lookup
goes first. Makronix's installer sets hosts: files mdnsd
dns, so the local file answers first, then the local network
names, then DNS. The local name
name.local is answered
by mdnsd8.
A machine that should answer DNS for a small network can run
unbound8
as a caching resolver, or nsd8
as an authoritative server. Both are packages; both have their own
documentation, and both should be reachable only from the network they
serve. The firewall chapter is the place to decide that.
DHCP
A client runs dhcpcd8
and needs no configuration beyond dhcpcd=YES. A
server runs dhcpd8
with a lease file and a subnet declaration:
# cat /etc/dhcpd.conf
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.199;
option routers 192.168.1.1;
option domain-name-servers 192.168.1.1;
default-lease-time 86400;
max-lease-time 604800;
}
# echo 'dhcpd=YES' >> /etc/rc.conf
# touch /var/db/dhcpd.leases
# /etc/rc.d/dhcpd start
The interface that serves the network must have a fixed address in
the same subnet (); a DHCP server with an
address from DHCP is a machine that cannot find itself. A machine that
should always get the same address can be pinned by its Ethernet
address:
host printer {
hardware ethernet 00:11:22:33:44:55;
fixed-address 192.168.1.50;
}
Time
A correct clock matters for TLS, for mail and for the logs of two
machines that are compared. ntpd8
is the daemon; /etc/ntp.conf names the servers:
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
With ntpd=YES, the clock is corrected
continuously and slowly. A clock that is wrong by hours is set once by
hand before the daemon starts:
# date 202611151200
# /etc/rc.d/ntpd restart
$ ntpq -p
ntpq -p lists the servers, the stratum and the
offset. A server marked with an asterisk is the one the daemon is
following. If none of them answers, the network or the firewall is the
problem, not the clock.