Skip to content

Instantly share code, notes, and snippets.

@devlucas
Last active March 29, 2018 03:13
Show Gist options
  • Save devlucas/fc412341f90a981ac652ccafb48c6bca to your computer and use it in GitHub Desktop.
Save devlucas/fc412341f90a981ac652ccafb48c6bca to your computer and use it in GitHub Desktop.
Run a local DNS server and have /etc/resolv.conf configured correctly on linux

If you ended up here looking for how to make your "nameserver 127.0.0.1" stick around nowadays, edit your /etc/resolvconf.conf and add the following:

# Defaults to /etc/resolv.conf if not set.

resolv_conf=/etc/resolv.conf

# Prepend name servers to the dynamically generated list.
# You should set this to 127.0.0.1 if you use a local name server other than libc.

name_servers=127.0.0.1

# If a local name server is configured then the default is just to specify that and ignore all other entries
# as they will be configured for the local name server.
# Set this to NO to also list non-local nameservers. This will give you working DNS
# even if the local nameserver stops functioning at the expense of duplicated server queries.

resolv_conf_local_only=NO

Then, apply the changes with:

# resolvconf -u

And check the result with:

$ cat /etc/resolv.conf # 127.0.0.1 should be the first entry, followed by your ISP DNS config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment