resolv.conf overwritten no matter what I do

Bug #92761 reported by Manuel López-Ibáñez
10
Affects Status Importance Assigned to Milestone
network-manager (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Although it works perfectly in Windows, in Kubuntu I need to put the DNS servers in /etc/resolv.conf. Otherwise, it will be overwritten by DHCP with the value:

nameserver 192.168.1.1

which doesn't work.

I prevented /etc/resolv.conf from being overwritten by modifying /etc/dhcp3/dhclient.conf

prepend domain-name-servers "212.158.248.6 83.146.21.5";
#supersede domain-name-servers "212.158.248.6 83.146.21.5";
request subnet-mask, broadcast-address, time-offset, routers,
 domain-name, host-name, netbios-name-servers, netbios-scope;

However, after a recent update in Edgy, that doesn't work anymore and resolv.conf is being overwritten all the time. I am using Knetworkmanager to connect to a wireless network.

Revision history for this message
Manuel López-Ibáñez (manuellopezibanez) wrote :

I had to comment out the following in /sbin/dhclient-script to prevent resolv.conf from being overwritten:

# make_resolv_conf() {
# if [ -n "$new_domain_name" -o -n "$new_domain_name_servers" ]; then
# # Find out whether we are going to mount / rw
# exec 9>&0 </etc/fstab
# rootmode=rw
# while read dev mnt type opts dump pass junk; do
# [ "$mnt" != / ] && continue
# case "$opts" in
# ro|ro,*|*,ro|*,ro,*)
# rootmode=ro
# ;;
# esac
# done
# exec 0>&9 9>&-

# # Wait for /etc/resolv.conf to become writable
# if [ "$rootmode" = "rw" ]; then
# while [ ! -w /etc ]; do
# sleep 0.1
# done
# fi

# local new_resolv_conf=/etc/resolv.conf.dhclient-new
# rm -f $new_resolv_conf
# if [ -n "$new_domain_name" ]; then
# echo search $new_domain_name >>$new_resolv_conf
# else # keep 'old' search/domain scope
# egrep -i '^ *[:space:]*(search|domain)' /etc/resolv.conf >> $new_resolv_conf
# fi
# if [ -n "$new_domain_name_servers" ]; then
# for nameserver in $new_domain_name_servers; do
# echo nameserver $nameserver >>$new_resolv_conf
# done
# else # keep 'old' nameservers
# sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p /etc/resolv.conf >>$new_resolv_conf
# fi
# chown --reference=/etc/resolv.conf $new_resolv_conf
# chmod --reference=/etc/resolv.conf $new_resolv_conf
# mv -f $new_resolv_conf /etc/resolv.conf
# fi
# }

What an awful hack...

Revision history for this message
Soren Hansen (soren) wrote : Re: [Bug 92761] resolv.conf overwritten no matter what I do

On Fri, Mar 16, 2007 at 09:55:06AM -0000, manu wrote:
> Although it works perfectly in Windows, in Kubuntu I need to put the
> DNS servers in /etc/resolv.conf. Otherwise, it will be overwritten by
> DHCP with the value:
>
> nameserver 192.168.1.1
>
> which doesn't work.

The obvious solution seems to fix your DHCP server. :-)

> I prevented /etc/resolv.conf from being overwritten by modifying
> /etc/dhcp3/dhclient.conf

Yes, that will not help. Network-manager takes care of editing your
resolv.conf, *UNLESS* you have the resolvconf package installed. Could
you try that?

Revision history for this message
Manuel López-Ibáñez (manuellopezibanez) wrote :

Soren Hansen wrote:
> On Fri, Mar 16, 2007 at 09:55:06AM -0000, manu wrote:
>> Although it works perfectly in Windows, in Kubuntu I need to put the
>> DNS servers in /etc/resolv.conf. Otherwise, it will be overwritten by
>> DHCP with the value:
>>
>> nameserver 192.168.1.1
>>
>> which doesn't work.
>
> The obvious solution seems to fix your DHCP server. :-)
>

I hate to say this but "It works perfectly on Windows". Plus, it is a
wireless router, I cannot "fix" anything (whatever "fix" you are seem to
be thinking about but forgot to mention).

>> I prevented /etc/resolv.conf from being overwritten by modifying
>> /etc/dhcp3/dhclient.conf
>
> Yes, that will not help. Network-manager takes care of editing your
> resolv.conf, *UNLESS* you have the resolvconf package installed. Could
> you try that?

The solution in my second comment works. So it seems to be a problem of
"dhclient". Perhaps a recent update broke dhclient-script handling of
dhclient.conf settings.

Revision history for this message
Soren Hansen (soren) wrote :

On Fri, Mar 16, 2007 at 11:32:41AM -0000, manu wrote:
> >> Although it works perfectly in Windows, in Kubuntu I need to put
> >> the DNS servers in /etc/resolv.conf. Otherwise, it will be
> >> overwritten by DHCP with the value:
> >>
> >> nameserver 192.168.1.1
> >>
> >> which doesn't work.
> > The obvious solution seems to fix your DHCP server. :-)
> I hate to say this but "It works perfectly on Windows". Plus, it is a
> wireless router, I cannot "fix" anything (whatever "fix" you are seem
> to be thinking about but forgot to mention).

I thought it was obvious that, as you pointed out that your nameserver
at 192.168.1.1 doesn't work, the fix would be to set up your dhcp server
to point to a DNS server that actually exists and works. If fail to see
how a nameserver you say doesn't work magically works under Windows,
though.

> >> I prevented /etc/resolv.conf from being overwritten by modifying
> >> /etc/dhcp3/dhclient.conf
> > Yes, that will not help. Network-manager takes care of editing your
> > resolv.conf, *UNLESS* you have the resolvconf package installed.
> > Could you try that?
> The solution in my second comment works. So it seems to be a problem
> of "dhclient". Perhaps a recent update broke dhclient-script handling
> of dhclient.conf settings.

Do you have the resolvconf package installed?

Revision history for this message
Manuel López-Ibáñez (manuellopezibanez) wrote :

Soren Hansen wrote:
> I thought it was obvious that, as you pointed out that your nameserver
> at 192.168.1.1 doesn't work, the fix would be to set up your dhcp server
> to point to a DNS server that actually exists and works. If fail to see
> how a nameserver you say doesn't work magically works under Windows,
> though.
>

192.168.1.1 is a router as a gateway. It acts as a DHCP server. The
nameserver understood by ubuntu from the DHCP reply is 192.168.1.1 (I am
not sure if that is the same for Windows, I'll check it though).
However, name lookup in Ubuntu doesn't work when using that nameserver
(it complains that the answer came from a different nameserver that the
one that was asked, I tested it with 'host' and 'dig'). All this works
in Windows (either Windows understands better the DHCP reply or it
doesn't care that the reply comes from a different nameserver, I cannot
test this right now because I don't have my machine in front of me).

>>>> I prevented /etc/resolv.conf from being overwritten by modifying
>>>> /etc/dhcp3/dhclient.conf
>>> Yes, that will not help. Network-manager takes care of editing your
>>> resolv.conf, *UNLESS* you have the resolvconf package installed.
>>> Could you try that?
>> The solution in my second comment works. So it seems to be a problem
>> of "dhclient". Perhaps a recent update broke dhclient-script handling
>> of dhclient.conf settings.
>
> Do you have the resolvconf package installed?
>

No, I don't. What it is going to solve? I will have to provide the
nameservers manually as well in /etc/resolvconf/resolv.conf.d/head. That
doesn't solve the problem that Windows can handle this automatically.
Neither it solves the issue that settings in /etc/dhcp3/dhclient.conf
are ignored by NetworkManager or /sbin/dhclient-script.

I am not the only one hitting this wall:

https://answers.launchpad.net/ubuntu/+ticket/2248
http://ubuntuforums.org/showthread.php?t=326050
http://www.ubuntuforums.org/showthread.php?t=241576
http://www.ubuntuforums.org/showthread.php?t=307758
http://www.ubuntuforums.org/showthread.php?t=305275
http://ubuntuforums.org/showthread.php?t=383670

(Given the above, I am sure this bug is a duplicate of something.)

Revision history for this message
Soren Hansen (soren) wrote :

On Fri, Mar 16, 2007 at 03:15:47PM -0000, manu wrote:
> >> The solution in my second comment works. So it seems to be a
> >> problem of "dhclient". Perhaps a recent update broke
> >> dhclient-script handling of dhclient.conf settings.
> > Do you have the resolvconf package installed?
> No, I don't. What it is going to solve?

It will not necessarily change a lot of things, but its presence or
absence makes a huge difference in how network-manager works.

Revision history for this message
Manuel López-Ibáñez (manuellopezibanez) wrote :

OK, I will try an report back.

Revision history for this message
Jared Greenwald (jetsaredim) wrote :

I'm seeing something similar with dhclient. This is nothing new to Feisty, but it's made more of a p.i.t.a. by Feisty.

Anyway, here's my story... I have a local gateway/router that runs its own nameserver (for my local network) and also is a namecache. that machine is 192.168.1.1 on my local network. So, under normal circumstances dhclient works just peachy. My problem is that I need to connect to my work via a VPN. As part of connecting to the VPN, I am supposed to get a new resolv.conf that corresponds to the network settings for the corporate network. This lasts for about 2-3 min and then is re-overwritten with the local network resolv.conf information.

Previously, I was able to use dhcpcd instead of dhclient(dhcp3), but with Feisty's network manager application, if I remove dhcp3 (and thus network manager), I end up getting errors from kde when opening things like konsole.

For now, I've been able to make progress by writing a script that just constantly brute-force copies the resolv.conf from my VPN connection at a steady interval.

I'd really like to know if there is an easier way to do this. Why is dhclient constantly updating the resolv.conf information?

Revision history for this message
Philip Paquette (pcpaquette) wrote :

Same problem here.

I'm using www.opendns.com as my main DNS servers, so I added "prepend domain-name-servers 208.67.222.222, 208.67.220.220;" to my /etc/dhcp3/dhclient.conf file so the dns servers would be added on top of the list each time I connect to the internet. This method seems to work well with "sudo dhclient eth1" and "sudo ifup eth1", but when I use network-manager, the file gets overwritten and the prepends line are removed.

But, by installing the resolvconf package, the /etc/resolv.conf is no longer modified by network-manager though.

However, I think this is a serious bug that should be fixed.
@Soren Hansen, could you explain why its presence or absence makes a huge difference in how network-manager works.

Thanks

Revision history for this message
Luis Alberto Pabón (copong) wrote :

This is extremely annoying and Networkmanager should definitely honour dhclient.conf when using dhcp.

Revision history for this message
Marco Cimmino (cimmo) wrote :

Soren please be respects people reporting bugs.
This is a bug from the time knetworkmanager was introduced.

knetworkmanager should never and I say never overwrite DNS in any way.
I have the same problem that 192.168.1.1 become the default one, doesn't matter if it works or not (here not), but MY personal dns should stay forever until I decide to change them.

This also affects a lot of wireless AP that are in dhcp and you cannot fix AP dhcp, and the result is you have to change dns every time you connect to them.
So please fix this so bad bug and respects people are trying to explain what is the problem.

Revision history for this message
Marco Cimmino (cimmo) wrote :

tried to install resolvconf but contrary than Jared Greenwald comment didn't solve my problem, dns are still overwritten by knetworkmanager.
Should we have to file against dhcp-client also?

Revision history for this message
Ashley Hooper (ash-hooper) wrote :

Exactly the same problem here.

Network Manager (or one of its helpers) seems to assume that the DHCP server is *always* a DNS caching server (i.e. that it will accept DNS queries on 53/UDP & 53/TCP, look up the results and return the resolved IP address to a client). This is by no means the case and is broken behaviour!

The router in the Net Cafe where I work (a fairly common NetGear DG824M) does not have a built in DNS server, but issues its upstream DNS servers to DHCP clients. Network Manager (or one of its helpers) blindly ignores these and instead puts 192.168.1.1 (my router's IP) into /etc/resolv.conf. Meanwhile, Windows & Mac wireless users connect effortlessly, whilst I have to edit /etc/resolv.conf each time I am allocated an IP address via DHCP.

This is a serious problem - especially for those who roam networks - and it is still a problem on the most recent version of Gutsy as at today.

The reason that there aren't more people reporting it is because most routers *do* act as DNS caching servers, but not all of them do and furthermore in some configurations this is not the desired configuration.

Also, prepending DNS servers sounds like a horrible kludge which would get especially messy with roaming networks, requiring modifications each time one connected to a new roamed network (not to mention it probably incurs performance degradation in name resolution).

We need Network Manager (or helpers) to do what the DHCP server tells it to which means to use the DNS server(s) it is given, and nothing else.

Revision history for this message
Marco Cimmino (cimmo) wrote :

I have noticed this about dns 192.168.1.1

under Windows this dns works for me, under Linux here doesn't work!
Well ping to www.google.com for ex. works, but for unknown reasons browsers and others things don't work!

So the problem when dhcp set this dns is under Linux doesn't work even if under Windows it works.
So more than one reason to not say "fix your router", because here we should only fix something under Linux.

If Soren would start to collaborate and tell us which tests we can do to investigate further the problem would be nice.

thanx for the attention
Marco

Revision history for this message
Ashley Hooper (ash-hooper) wrote :

Please ignore my last comment in its entirety. I have just checked again and my laptop *is* getting the correct nameservers from the router's DHCP configuration. It is *not* over-riding this and trying to use the router itself as a resolver.

Network Manager does take a little while to handshake, etc so perhaps this is why I thought it wasn't working. As far as I am concerned, this is no longer a problem for me.

Revision history for this message
Alexander Sack (asac) wrote :

network-manager will use whatever your dhcp server announces as dns server. ashley confirmed that it works, so this bug is fixed from what i see.

Changed in network-manager:
status: New → Fix Released
Revision history for this message
Marco Cimmino (cimmo) wrote :

ok Alexander you are right anyway why in your opinion under Windows I can use 192.168.1.1 ad DNS and under Linux I have to specify DNS from my provider?

This is very common not only on my pc but also others I have installed Ubuntu.
Should I open a new bug for this issue?

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.