Force OpenBSD to use unbound(8) DNS resolver in DHCP client mode

By default, a DHCP client gets an IP address, a network gateway and a DNS server. That’s fine most of the time. But if you own an OpenBSD cloud instance that has to use DHCP to get online, you might not be satisfied with the domain-name-servers option provided by your DHCP server. Hopefully, OpenBSD provides an easy way to force your DNS:

# viĀ /etc/dhclient.conf
(...)
prepend domain-name-servers 127.0.0.1;

Since then, OpenBSD will use our DNS resolver. Which is… unbound(8)

# rcctl enable unbound
# rcctl start unbound

Note that this configuration allows to use the DNS server provided by the DHCP server as a fallback.

Debian Linux, from DHCP to static IP

Switching from DHCP to static IP on a Debian system requires only a few steps:

# /etc/init.d/networking stop
# vi /etc/network/interfaces
(...)
allow-hotplug eth0
#iface eth0 inet dhcp
iface eth0 inet static
	address 192.168.0.62
	netmask 255.255.255.0
	gateway 192.168.0.1
	broadcast 192.168.0.255
	network 192.168.0.0
(...)
# reboot

That’s All Folks!