DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 6th November 2010
guitarscn guitarscn is offline
Package Pilot
 
Join Date: Oct 2008
Posts: 166
Default 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
Where "nameserver 192.168.1.1" and "nameserver 55.55.55.55" might change accordingly by itself at any point, but I'd like "nameserver 127.0.0.1" to always be there first all the time. Is this possible?
Reply With Quote
  #2   (View Single Post)  
Old 6th November 2010
rocket357's Avatar
rocket357 rocket357 is offline
Real Name: Jonathon
Wannabe OpenBSD porter
 
Join Date: Jun 2010
Location: 127.0.0.1
Posts: 429
Default

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.
Reply With Quote
  #3   (View Single Post)  
Old 6th November 2010
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Banned
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Default

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).
Reply With Quote
  #4   (View Single Post)  
Old 6th November 2010
guitarscn guitarscn is offline
Package Pilot
 
Join Date: Oct 2008
Posts: 166
Default

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.
Reply With Quote
  #5   (View Single Post)  
Old 6th November 2010
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Banned
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Default

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?
Reply With Quote
  #6   (View Single Post)  
Old 6th November 2010
guitarscn guitarscn is offline
Package Pilot
 
Join Date: Oct 2008
Posts: 166
Default

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?
Reply With Quote
  #7   (View Single Post)  
Old 9th November 2010
tehsean tehsean is offline
Custom User
 
Join Date: Aug 2010
Posts: 22
Default

Quote:
Originally Posted by guitarscn View Post
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?
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.
Reply With Quote
  #8   (View Single Post)  
Old 9th November 2010
passthejoe passthejoe is offline
Real Name: Steven
Port Guard
 
Join Date: Oct 2010
Location: Los Angeles
Posts: 30
Default

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.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT. The time now is 06:03 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick