The Debian image on the Hetzner CX servers is configured to use the ISC dhcpclient, which in turn is configured to get all kind of staff, including the domain-name-servers from the DHCP server.

These must be disabled for localhost resolution.

See:

Instructions

  • sudo editor /etc/dhcp/dhclient.conf
  • Comment out the complete request section
  • Add the following request section and supersede instructions
request subnet-mask, broadcast-address, time-offset, routers, rfc3442-classless-static-routes;
supersede domain-name-servers 127.0.0.1;
  • Stop dhclient from modifying /etc/resolv.conf
sudo true

cd /etc/dhcp/dhclient-enter-hooks.d || cat >&2
sudo sed wleave_resolv_conf_alone <<EOF
# $USER $(date -uIs)

make_resolv_conf() { :; }
EOF

sudo chmod +x leave_resolv_conf_alone