LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   how to automatically disable unreachable primary DNS? (https://www.linuxquestions.org/questions/linux-networking-3/how-to-automatically-disable-unreachable-primary-dns-101793/)

Eabin 10-08-2003 04:59 PM

how to automatically disable unreachable primary DNS?
 
hi all!

I get my network-information via DHCP. The problem is, my provider's DHCP server sends a primary DNS that is down. The secondary works well. So if i swap the two entries in /etc/resolv.conf, everything is fine. but after next reboot, order is wrong again.

Windows XP just ignores the broken DNS, and uses the secondary all the time, but all linux apps insist on connecting to first DNS first, and i get a 5 to 30 seconds delay in connections to any server :( Is it possible to tell linux networking that is should disable the broken DNS entry somehow? i mean, isn't this the purpose of a secondary DNS?

thanks in advance,
-erwin

mlp68 10-08-2003 10:33 PM

I had the same problem once. I'm sure there's a more solid solution, but this crude thing worked for me:

usually there's a hook for a program or script
/sbin/ifup-local to be run at the end of the interface configuration (look at the end of
/etc/sysconfig/network-scripts/ifup-post -- if such an executable exists, it's being run. ).

Ok. Put the following script as /sbin/ifup-local, make it executable.

Quote:

#! /bin/sh
# mlp -- remove the first stale DNS entry from /etc/resolv.conf

[ "$1" != "eth0" ] && exit 0

TEMPFILE=`mktemp -q /tmp/$$.XXXXXX`

for ns in `/bin/cat /etc/resolv.conf | /bin/grep nameserver | /usr/bin/awk '{print $2}' ` ; do


if ! /bin/ping -q -n -c 1 $ns >/dev/null 2>&1 ; then

/bin/grep -v $ns /etc/resolv.conf > $TEMPFILE
/bin/cat $TEMPFILE > /etc/resolv.conf
/bin/rm -f $TEMPFILE
exit 0

fi

done
Ok, it cannot handle 2 stale out of 3 name servers, assumes that there's only one stale one, but probably it's good enough.

It also assumes that you can actually ping the nameserver.

Hope it helps,
mlp

gamu829 10-09-2003 01:38 AM

Another possible solution is to send your ISP an email every hour or so telling them their DHCP server(s) are giving out dead DNS servers. Tell them this is unacceptable and that if they can't fix it, that you can find another ISP.

Greg

Looking_Lost 10-09-2003 05:48 AM

If your using dhcpcd you can add the -R option to it and it won't modify your resolv.conf everytime it's used, it'll leave the entries the way you have them.

Then shout at your ISP :)

Eabin 10-09-2003 08:53 AM

thanks for you suggestions, they will do the job. (except threatening my ISP, because where i live there's no alternative broadband ISP :( )

but i'm still wondering if there is a "clean" solution to the problem, so it works as flawlessly as windows (i always thought linux is far superior when it comes to networking)

rufius 10-09-2003 09:29 AM

Linux is superior, but it requires a bit more hands on than Windows, Windows is made for the dummy user that needs the computer to do it for them, so therefore problems with DNS are done in the background. Linux though takes everything very... "literally" so to speak therefore it is superior, but the basis of its superiority is the control you can have over the OS because you're fixing the aforementioned problems yourself rather than relying on automation to do it for you.

Eabin 10-09-2003 05:48 PM

i don't mean to start a flamewar or something, but the best thing(TM) would seem to have all the control you have now - if you want to. but still the system shouldn't get painfully slow if something happens, that is to be forseen - because there is actually a reason for a second DNS, and this is not slowing down ping times :)


All times are GMT -5. The time now is 05:23 AM.