0

I wish to add more DNS nameservers such as 8.8.8.8 in OpenBSD 5.7. I understand that the current version of OpenBSD allows up to a maximum of three DNS nameservers.

I have read the man pages related to the following relevant topics of networking in OpenBSD:

hostname.if

http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man5/hostname.if.5?query=hostname.if&sec=5

dhclient

http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/dhclient.8?query=dhclient&sec=8

resolv.conf, resolv.conf.tail

http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man5/resolv.conf.5?query=resolv.conf.tail&sec=5

dhclient.conf

http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man5/dhclient.conf.5?query=dhclient.conf&sec=5

ifconfig

http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man8/ifconfig.8?query=ifconfig&sec=8

Which of the above items must I edit in order to add more DNS nameservers?

3 Answers 3

2

If you're just trying to specify the nameservers that the system uses (which I'm guessing you are, based on this question you asked before), you simply need to edit /etc/resolv.conf.

At a minimum, it should look something like:

lookup file bind
nameserver 8.8.8.8
nameserver 8.8.4.4

I've specified Google's public DNS servers there, but amend the nameserver lines as necessary to use others (eg, your ISP's DNS servers, OpenDNS, etc).

For more information on the file contents and other values you can include, see the resolv.conf manual page.

10
  • The first line of my /etc/resolv.conf contains 192.168.1.1. I don't know how it got there. My router's default gateway is 192.168.220.1. I removed it by becoming a superuser (root) first and using a text editor for the purpose. After reboot, it reappeared. I tried it many times and failed. First question: Is it safe for me to remove it? Second question: If yes, how to remove it permanently?
    – virvegto
    Jul 16, 2015 at 8:36
  • 1
    @virvegto If your resolv.conf is getting automatically updated, I can only think it's the DHCP client on your OpenBSD machine that's doing it. The server it's getting its IP from is pushing that IP to it. The the FAQ for more information. Basically, remove the domain-name-servers option from /etc/dhclient.conf to stop /etc/resolv.conf from being updated automatically. Alternatively, you can configure your DHCP server to pass the correct DNS server(s) to your OpenBSD machine.
    – mjturner
    Jul 16, 2015 at 8:47
  • 1
    @virvegto Ok, if that DNS server is coming from your ISP you will need to make sure you can connect to public DNS servers before disabling resolv.conf updates. You can test this by removing your ISP's DNS server from resolv.conf and replacing it with the Google entries and seeing if you can still lookup hostnames (eg, nslookup www.openbsd.org). As an aside, what is your router's IP address?
    – mjturner
    Jul 16, 2015 at 11:29
  • 1
    @virvegto If the public DNS servers work, you will need to change /etc/dhclient.conf, as I mentioned in an earlier comment. As long as you can connect to the DNS servers, changing the setting shouldn't "break" your internet connection or lead to instability.
    – mjturner
    Jul 16, 2015 at 13:17
  • 1
    @virvegto You can, but your ISP's DNS server will remain there.
    – mjturner
    Jul 16, 2015 at 13:25
1

If I'm reading the code correctly, the maximum number is now 5.

So you could change it in asr_private.h and re-compile (make obj?).

But why are you doing this? If it's anything like Linux/glibc, each query is done in series, with a 5-second timeout, so even going beyond 3 implies the query will take at least 15 seconds if the first three aren't working.

Does your application wait that long for DNS lookups?

You may be better off running a caching nameserver locally, for example dnsmasq, Unbound, or BIND.

See also: http://comments.gmane.org/gmane.os.openbsd.misc/209494

2
  • Thanks for letting me know that the maximum is 5, not 3.
    – virvegto
    Jul 16, 2015 at 8:30
  • Does your application wait that long for DNS lookups? Yes, it does. I don't know why. Firefox takes a long time, about 45 seconds, launch on OpenBSD 5.7.
    – virvegto
    Jul 16, 2015 at 8:41
-1
  • To release current lease, run (as root)
    ~# dhclient -r interface
    
  • To obtain a new lease from your vpn_gateway which will update /etc/resolv.conf:
    ~# route_vpn_gateway=(ipv4 gw_addr)
    ~# echo "prepend domain-name-servers $route_vpn_gateway;" > /etc/dhclient.conf
    ~# dhclient interface
    
2
  • Could it be that the route_vpn_gateway=(ipv4 gw_addr) was meant to be $(ipv4 gw_addr)?
    – AdminBee
    Sep 21, 2020 at 12:39
  • I get the environment variable $route_vpn_gateway supplied from openvpn as part of configuring the vpn
    – Colin Tree
    Apr 22, 2021 at 3:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .