# Solved]Using extra dns, preventing overwrite of resolv.conf?

## Letharion

I've set up an internal DNS (bind) on my network, so I can ssh to all hostnames from all hosts, without needing to update /etc/hosts and/or remembering IP-adresses.

Adding

```
search myfakedomain.com

nameserver 192.168.1.2
```

to my resolv.conf makes this work wonderfully.

Problem is, dhcpcd overwrites this file on boot, which makes the whole thing far less convinient.

What is the best/easiest way to remedy this situation?Last edited by Letharion on Fri May 07, 2010 7:38 am; edited 1 time in total

----------

## UberLord

Update your DHCP server to point DNS to your new bind instance

----------

## Letharion

That dhcp belongs to my ISP, so that's gonna be pretty hard ^^

Sorry, should have mentioned how my network was set up.

I added an init-script that simply writes the information to resolv.conf on boot. Works well, is really ugly.

I also tried setting a-w on resolv.conf, but dhcpcd runs as root and didn't care to much for permissions, which makes sense ofc.

Cleaner solutions that don't require me to run a dhcpd too?

----------

## Mousee

Have you taken a look at /etc/conf.d/net.example? (Assuming you have it still)

```

# GENERIC DHCP OPTIONS

# Set generic DHCP options like so

#dhcp_eth0="release nodns nontp nonis nogateway nosendhost"

# This tells the dhcp client to release its lease when it stops, not to

# overwrite dns, ntp and nis settings, not to set a default route and not to

# send the current hostname to the dhcp server and when it starts.

# You can use any combination of the above options - the default is not to

# use any of them.

```

So you might consider adding "nodns" to your DHCP options. 

I believe there's also /etc/resolv.conf.head, which adds any nameservers you set there to the very top of resolv.conf.

Also, BIND is overkill for a home network. You should consider using net-dns/dnsmasq instead.

----------

## Letharion

 *Quote:*   

> So you might consider adding "nodns" to your DHCP options. 

 

I hadn't looked at net.example, but that looks useful.

```
I believe there's also /etc/resolv.conf.head, which adds any nameservers you set there to the very top of resolv.conf.
```

I don't have a resolv.conf.head, but that would be the perfect solution,  I'm gonna try it and see if it's used.  :Smile: 

 *Quote:*   

> Also, BIND is overkill for a home network. You should consider using net-dns/dnsmasq instead.

 

Yeah, I'm pretty sure of that too, but I happen to know how to conf bind, and not dnsmasq, so it was really easy for me to copy an already existing conf and alter it a bit. I appreciate the suggestion however, maybe I will have a look at it next time  :Smile: 

----------

## Mousee

 *Letharion wrote:*   

> 
> 
> ```
> I believe there's also /etc/resolv.conf.head, which adds any nameservers you set there to the very top of resolv.conf.
> ```
> ...

 

Ya it shouldn't be there by default. You just create it (vim /etc/resolv.conf.head or whatever), add in whatever hosts you want, and away it goes!  :Razz: 

 *Quote:*   

> 
> 
> Yeah, I'm pretty sure of that too, but I happen to know how to conf bind, and not dnsmasq, so it was really easy for me to copy an already existing conf and alter it a bit. I appreciate the suggestion however, maybe I will have a look at it next time 

 

Aye no worries - I know both quite well and dnsmasq is, once you get to know it, far easier/quicker to setup than BIND - not to mention a lot "lighter" (at both runtime and takes up less diskspace). As you already had a pre-existing config for BIND though it just makes sense to go that route  :Smile: 

----------

## Letharion

 *Quote:*   

> 
> 
> Ya it shouldn't be there by default. You just create it (vim /etc/resolv.conf.head or whatever), add in whatever hosts you want, and away it goes! 
> 
> 

 

This works, and does exactly what I want  :Smile: 

----------

