I was given the files for a mini linux, that boots directly into firefox. It works for all it should be doing, only that I do not get an internet connection.

We have 3 DNS servers in the network, which all work. I can ping them, too. But when trying to ping google.de or wget google.de I get a bad address error.

nslookup google.de works for some reason.

I tracked the issue down to my resolv.conf on the booted system not having the same contents as the resolv.conf that I put into the .iso file.

I tried understanding all the factors that go into creating and modifying resolv.conf. I'm not quite sure I got it all, but I definitely didn't find my solution there.

So as a last ditch effort, I tried making the resolv.conf file immutable using

:~# chattr +i /etc/resolv.conf

When rebuilding and booting again to my surprise my file was renamed to resolv.conf~ and in its place was the same standard file that has been haunting me.

The file contents make me believe it gets the information from the network itself. When starting the .iso in Virtualbox without internet access, my file is being kept as it is.

I tried changing /etc/dhcp/dhclient.conf to not get the information from the net, by deleting domain-name-server and domain-name-search from the request part of the file.

Didn't work unfortunately.

I don't have the NetworkManager installed. The iso is based on Ubuntu 14.04.

There is probably vital information missing. I'm happy to provide it.

UPDATE:

I think I found the file that clears resolv.conf.

It seems to be /usr/share/udhcpc/default.script

#!/bin/sh

# udhcpc script edited by Tim Riker <Tim@Rikers.org>

[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1

RESOLV_CONF="/etc/resolv.conf"
[ - n "$broadcast" ] && BROADCAST="broadcast $broadcast"
[ -n "$subnet" ] && NETMASK="netmask $subnet"

case "$1" in
    deconfig)
        /bin/ifconfig $interface 0.0.0.0
        for i in /etc/ipdown.d/*; do
            [ -e $i ] && . $i $interface
        done
        ;;

    renew|bound)
        /bin/ifconfig $interface $ip $BROADCAST $NETMASK

        if [ -n "$router" ] ; then
            echo "deleting routers"
            while route del default gw 0.0.0.0 dev $interface ; do
                :
            done

            metric=0
            for i in $router ; do
                route add default gw $i dev $interface metric $((metric++))
            done
        fi

        echo -n > $RESOLV_CONF # Start ----------------  
        [ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
        for i in $dns ; do
            echo adding dns $i
            echo nameserver $i >> $RESOLV_CONF
        done
        for i in /etc/ipup.d/*; do
            [ -e $i ] && . $i $interface $ip $dns 
        done # End ------------------
        ;;
esac

exit 0

It's part of the udhcpc program. A tiny dhcp client, that is part of busybox

Will investigate further.


UPDATE2 AND SOLUTION:

I commented the part out (#Start to #End), that seemingly overwrites the /etc/resolv.conf file and sure enough. That was the culprit. So an obscure script caused all this trouble.

I changed the question to reflect, what actually needed to be known to solve my problem, so it would be easier to find for people with the same problem and so I could accept an answer.

Thanks for the help here in figuring things out.

share|improve this question
1  
Setting the immutable flag on resolv.conf doesn't work as you expected as the file was not changed. The directory entry in /etc was changed when the file was renamed. You'd have to set /etc to be immutable - something you really don't want to do. – Doug O'Neal Dec 15 '14 at 15:56
    
@DougO'Neal I see. Thanks for the heads up. – Minix Dec 15 '14 at 16:33
up vote 12 down vote accepted

1) You shouldn't manually update your resolv.conf, because all changes will be overwritten by data that your local DHCP server provides. If you want it to be static, run sudo dpkg-reconfigure resolvconf and answer "no" to dynamic updates. If you want to add new entries there, edit /etc/resolvconf/resolv.conf.d/base and run sudo resolvconf -u, it will append your entries and DHCP server's entries.

2) Try to edit your /etc/network/interfaces and add your entries there, like

auto eth0 
iface eth0 inet dhcp 
dns-search google.com 
dns-nameservers dnsserverip 

and then restart /etc/init.d/networking restart or sudo ifdown -a and sudo ifup -a

3) Your system uses udhcp which is a very small DHCP client program. The udhcp client negotiates a lease with the DHCP server and notifies a set of scripts when a leases is obtained or lost. You can read about it's usage here or just edit this script (as you did).

share|improve this answer
    
I did add the entries into the /etc/resolvconf/resolv.conf.d/base and ran resolvconf -u. It didn't work, unfortunately. – Minix Dec 15 '14 at 14:41
    
Have you tried to run sudo dpkg-reconfigure resolvconf? After running resolvconf -u, your entries wasn't in result file? How did you add them, like "nameserver 127.0.0.1" or "search google.com"? – kirill-a Dec 15 '14 at 14:55
    
I did run dpkg-reconfigure resolvconf. The entries were not in there. And I have entries with both nameserver ip and search domain. – Minix Dec 15 '14 at 14:59
    
No, running dpkg-reconfigure resolvconf won't add entries, but you can disable automatic updates. If you disable updates, you can edit resolv.conf manually and it shouldn't be overwritten. – kirill-a Dec 15 '14 at 15:04
    
My bad for phrasing it so clumsily, I was answering your comment sentence by sentence. After running resolvconf -u the entries were not added. – Minix Dec 15 '14 at 15:06

I ran into this too. Commenting out domain-name-server didn't fix it for me either.

Also, I'm not using resolvconf, just plain /etc/resolv.conf.

I didn't try using chattr +i to lock down resolv.conf because it seems too hacky. Also, I want Puppet to be able to modify resolv.conf when necessary.

The best solution I found overrides the default behavior of dhclient using its documented hooks.

Create a new file at /etc/dhcp/dhclient-enter-hooks.d/nodnsupdate with the following contents:

#!/bin/sh
make_resolv_conf() {
    :
}

Then make the file executable:

chmod +x /etc/dhcp/dhclient-enter-hooks.d/nodnsupdate

Now when dhclient runs -- either on reboot or when you manually run sudo ifdown -a ; sudo ifup -a -- it loads this script nodnsupdate. This script overrides an internal function called make_resolv_conf() that would normally overwrite resolv.conf and instead does nothing.

This worked for me on Ubuntu 12.04.

share|improve this answer

I had the same problem and I edited my `/etc/dhcp/dhclient.conf' file by adding domain-name and domain-name-servers

supersede domain-name "local.com"; supersede domain-name-servers 192.168.56.103;

192.168.56.103 is my vm running bind9 and my domain name is local.com

and I have removed the same from request section as well.

share|improve this answer

go to this directory:

  cd /etc/resolvconf/resolv.conf.d

Open the file named head and put the DNS IPs or names in there. Open the file named tail and put the domain in there. Reboot.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.