linux DNS

Red Squirrel

No Lifer
May 24, 2003
70,633
13,821
126
www.anyf.ca
How can I tell a linux server what DNS servers to look at? /etc/resolv.conf is simply generated by a script and gets overwritten regularly, so I need a way to set a permanent DNS. Preferably I'd like to set it per interface, as I have 2 interfaces on different IP ranges.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
/etc/resolv.conf is the file that holds this configuration. Find out which script is overwriting it and destroy it with a vengence.

If it's a DHCP related script there should be a way to make it stop doing that.
 

QED

Diamond Member
Dec 16, 2005
3,428
3
0
If it's being overwritten, you need to find out who is doing it, and why.

It would be even better if you told us which flavor of Linux you are running, as many of them now come with their system administration control panel which lets you set these paremeters using a GUI.

 

cleverhandle

Diamond Member
Dec 17, 2001
3,566
3
81
Originally posted by: RedSquirrel
/etc/resolv.conf is simply generated by a script and gets overwritten regularly, so I need a way to set a permanent DNS.
Like n0c said, this is probably a DHCP script at work. There's should be a dhclient.conf file in /etc/dhcp (or similar) where you tell the dhcp client what parameters to request. Just remove "domain-name-servers" from that list.
Preferably I'd like to set it per interface, as I have 2 interfaces on different IP ranges.
That doesn't make any sense. Your nameserver has nothing to do with interfaces. You set the nameserver in resolv.conf and the networking subsystem looks at that IP address and figures out what interface to send to using the kernel routing table. As with your earlier posts, you're being led astray by the Windows GUI version of TCP/IP networking.

 

Red Squirrel

No Lifer
May 24, 2003
70,633
13,821
126
www.anyf.ca
As far as I know whenever the IP is renewed the resolv.conf file gets overwritten by /sbin/dhclient-script with the DNS info from the DHCP server, which is normal... I think. With static IP this is different I think.

I'm running FC5.

Also, how do I get linux to detect a 2nd network card? I just added another but I dont get eth1 show up. This is in vmware so the card would be the same model as eth0. (AMD pci adapter)
 

cleverhandle

Diamond Member
Dec 17, 2001
3,566
3
81
Originally posted by: RedSquirrel
As far as I know whenever the IP is renewed the resolv.conf file gets overwritten by /sbin/dhclient-script with the DNS info from the DHCP server, which is normal... I think. With static IP this is different I think.
Yes, if you use a static IP (and thus don't use dhcp) it won't get overwritten. So what are you asking?
Also, how do I get linux to detect a 2nd network card? I just added another but I dont get eth1 show up. This is in vmware so the card would be the same model as eth0. (AMD pci adapter)
It should get detected at boot when discover runs, but vmware could mess that up. See if you can add another card manually through the network manager GUI.
 

Red Squirrel

No Lifer
May 24, 2003
70,633
13,821
126
www.anyf.ca
Managed to get eth1 to show up, and I set both interfaces as static just to simplify things, and I cant find any /etc/dhcp (or similar, just did d tab).

When I do service network restart it still overwrites /etc/resolv.conf. So is there another file to tell it where to look for dns servers? If I edit it, it wont take affect so i'm guessing service network restart is only way to load this info, but that overwrites the file...
 

cleverhandle

Diamond Member
Dec 17, 2001
3,566
3
81
There's a DNS tab in FC's network manager - is that set correctly?

Otherwise, I don't know. You'll have to look around for the script and figure out what's going on. Doing a grep -R 'resolv.conf' /etc/init.d should give you a place to start.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: RedSquirrel
Managed to get eth1 to show up, and I set both interfaces as static just to simplify things, and I cant find any /etc/dhcp (or similar, just did d tab).

When I do service network restart it still overwrites /etc/resolv.conf. So is there another file to tell it where to look for dns servers? If I edit it, it wont take affect so i'm guessing service network restart is only way to load this info, but that overwrites the file...

Nothing should be overwriting that file.

The changes should take affect basically as soon as they are entered.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
Nothing should be overwriting that file.

That's not true, lots of things should be able to update that file. The problem is coordinating them all, which is where something like resolvconf comes into play.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Nothinman
Nothing should be overwriting that file.

That's not true, lots of things should be able to update that file. The problem is coordinating them all, which is where something like resolvconf comes into play.

dhcp is the only thing I can think of. What else should be messing with it? And what's resolvconf?
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
dhcp is the only thing I can think of. What else should be messing with it? And what's resolvconf?

VPN and PPP clients come to mind.

Copy/paste from 'apt-cache show resolvconf':

Resolvconf is a framework for keeping track of the system's
information about currently available nameservers. It sets
itself up as the intermediary between programs that supply
nameserver information and programs that use nameserver
information.
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Originally posted by: Nothinman
dhcp is the only thing I can think of. What else should be messing with it? And what's resolvconf?

VPN and PPP clients come to mind.

I lumped those in with dhcp. :p And those aren't really things that would change it without you knowing (and that should be configurable anyhow).
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
I lumped those in with dhcp.

But they're not the same thing and you can have all 3 installed at once fighting with each other.

And those aren't really things that would change it without you knowing (and that should be configurable anyhow).

It's not so much about you not knowing it as it is having a way to control how it's updated when you have more than one of those connections at once.