|
OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below. |
|
Thread Tools | Display Modes |
|
|||
How to add a nameserver in /etc/resolv.conf automatically
Okay, so it seems every time I reboot (or maybe every time I connect to the internet) it seems /etc/resolv.conf gets reset and everything I added before is gone. How can I make it so that it can change itself dynamically as needed, but always keep one line in there? I want to keep "nameserver 127.0.0.1" on top, right after the 'search' line which is the very 1st line in the file. So for example I want it like:
Code:
search blah nameserver 127.0.0.1 nameserver 192.168.1.1 nameserver 55.55.55.55 |
|
||||
http://www.openbsd.org/cgi-bin/man.c...tail&sektion=5
Pay special attention to /etc/resolv.conf.tail. It won't add it in first like you want I don't think, but that's the closest I've seen to what you're asking for. |
|
|||
The only way that /etc/resolv.conf gets changed is if you're running dhclient(8) on a network interface.. the client will populate the file with a nameserver offered by a dhcp daemon/server.. either your own or your ISP's.
You can create a file called /etc/resolv.conf.tail and add your own additional settings, but to supersede the information from dhcp you need to instruct the client to do so. To do this you'll need to edit /etc/dhclient.conf, you can add simply: supersede domain-name-servers 127.0.0.1; But you may wish to read more about the other options available to you, see dhclient.conf(5). |
|
|||
I'd still like /etc/resolv.conf to be populated by the normal nameservers, but in addition I just need 127.0.0.1 to be first on the list because of dsocks, where I'd like to surf the web or ssh anonymously without leaking DNS. At least that's what dsocks's man pages tell me, that it needs to be first on the list. I guess I can always add in the line manually every boot, but it'd be nice if I could make it be done automatically.
|
|
|||
It might be possible to use "prepend" in place of "supersede" in this context, as is mentioned in the man page.
So try the following instead, it should add 127.0.0.1 and then the other servers: prepend domain-name-servers 127.0.0.1; Does that work for you? |
|
|||
That seems to work. Would this option be the same as editing /etc/resolv.conf by hand and adding the 'nameserver 127.0.0.1' in? Or is dhclient doing more because I put it in /etc/dhclient.conf and starting dhclient?
|
|
|||
I use one network that uses dynamic addressing but doesn't set nameservers, and I've had success in the past with /etc/resolv.conf.tail to keep "good" dns server addresses around.
|
|
|||
FWIW, I hop around on networks a lot, so I just have my ifconfig, dhclient and nameserver add ons in a shell script. Works for me, but is admittedly less sophisticated.
Last edited by tehsean; 9th November 2010 at 12:13 PM. Reason: BSDfan666 already summed it up. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Authoritative only BIND nameserver for local domain | J65nko | Guides | 2 | 7th December 2009 07:08 AM |
Best way to check if freebsd server is running a nameserver service/daemon | Yuka | FreeBSD General | 7 | 6th November 2008 01:26 AM |
start xscreensacer automatically | rex | FreeBSD General | 2 | 15th October 2008 05:24 PM |
Login automatically | map7 | FreeBSD General | 1 | 12th October 2008 11:09 PM |
difference between rc.conf and loader.conf | disappearedng | FreeBSD General | 5 | 3rd September 2008 05:54 AM |