A better solution is to use dnsmasq. Install, configure and forget. No more scripts to query the BSNL DNS servers and then update /etc/resolv.conf.
dnsmasq FAQ:
here.
dnsmasq configuration: edit /etc/dnsmasq.conf ensuring
Code:
resolv-file=/etc/resolv.dnsmasq.conf
listen-address=127.0.1
Create /etc/resolv.dnsmasq.conf with all the known BSNL DNS servers:
Code:
# Override default 5 second timeout because BSNL DNS servers often out of service
timeout:1 <== EDIT: this syntax is wrong! Should be options timeout:1
# List all known BSNL DNS servers. dnsmasq will discover the best and use them
nameserver 61.1.96.69
nameserver 61.1.96.71
nameserver 61.1.96.72
nameserver 218.248.240.23
nameserver 218.248.240.135
nameserver 218.248.240.180
nameserver 218.248.240.181
nameserver 218.248.240.208
nameserver 218.248.255.139
nameserver 218.248.255.145
nameserver 218.248.255.146
Edit /etc/resolv.conf to include 127.0.0.1. Here's mine
Code:
# Override default 5 second timeout because BSNL DNS servers often out of service
timeout:1 <== EDIT: this syntax is wrong! Should be options timeout:1
# Only 3 nameservers are used (see man page).
nameserver 127.0.0.1
nameserver 218.248.240.23
nameserver 218.248.240.208
As long as dnsmasq is working OK the ones after 127.0.0.1 are not used.
If you want to see what dnsmasq is doing, add this line to /etc/dnsmasq.conf
and see /var/log/daemon.log. Warning: lots of logging!
To get dnsmasq to restart, so it re-reads its configuration files:
Code:
/etc/init.d/dnsmasq restart
If you want to see which DNS servers dnsmasq is using:
Code:
grep /var/log/debug forwarded