How do I determine the ip-addresses of ISP's DNS name servers?
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
How do I determine the ip-addresses of ISP's DNS name servers?
I am looking for a command which, when typed from the command line, returns the ip-addresses of the DNS nameservers that my ISP is using.
I think is should be technically possible to write a program that does this, because linux installers set up /etc/resolv.conf correctly (as does knoppix). But I've been unable to find a command that does it. Is there one, and if so, what is it called? Thanks.
cannabis:/home/repo# host -t ns edpnet.be
edpnet.be name server ns2.edpnet.be.
edpnet.be name server ns3.edpnet.be.
edpnet.be name server ns1.edpnet.be.
cannabis:/home/repo#
cannabis:/home/repo# host -t ns edpnet.be
edpnet.be name server ns2.edpnet.be.
edpnet.be name server ns3.edpnet.be.
edpnet.be name server ns1.edpnet.be.
cannabis:/home/repo#
The command you quoted retrieves the name servers responsible for the edpnet.be domain, *NOT* the DNS servers that one should use to lookup general queries on ones pc.
NorwegianBlue, the reason your networking layer can determine the DNS servers to use, is because it is using DHCP (Dynamic Host Configuration Protocol). Basically, when you start your computer, it transmits on the broadcast address (255.255.255.2555) something like `HEY GUYS; WHO AM I?'. If there is a DHCP server listening on the node you are on, and it recognizes your MAC (Media Access Control) address (unique hardware address of your card), it well reply back saying "YOU ARE xxx.xxx.xxx.xxx (IP), subnet xxx.xxx.xxx.xxx, gateway xxx.xxx.xxx.xxx, and use xxx.xxx.xxx.xxx as DNS server, and xxx.xxx.xxx.xxx as your backup dns server.
Apart from direct ISP DHCPd leases, if you 'links -dump whatismyip.org' you have your external IP address, then if you resolve that with say 'host' you have your hostname, then if you 'dig NS "yourhostname"' it should return one or more DNS servers?..
That is the Domain name server responsible for DNS lookups for the blueyonder.co.uk domain. The actual IP addresses that come down DHCP are different, and when I do a reverse lookup on them, they don't even translate in host-names.
Yes, I realise that NorwegianBlue, you are trying to find out your resolvers.
I stand by my statement that this is provided via DHCP.
Unless you write your own program that implements the DHCP protocol, the only way to find out, is either contact your ISP, or let your network initialise, then check /etc/resolv.conf.
I think is should be technically possible to write a program that does this, because linux installers set up /etc/resolv.conf correctly (as does knoppix).
It's not actually the installers that setup /etc/resolv.conf. In a DHCP system, that file is generated new for every boot, and populated by the dhclient program with information received from the DHCP server that responds and leases an IP to it. You should be able to find the source code for dhclient and look through that. You might be able to get more information by simply googling dhclient. Often it's good enough to just use the IP of your gateway. In a commercial system that uses fixed IPs, you normally get the nameserver info from your system admin.
Thanks all. resolv.conf is obviously re-created by knoppix, and quite possibly by other distro's as well when doing dhcp, but it isn't rewritten when using static addressing in debian - or at least not when I have modified the file - my modifications are preserved when rebooting. The reason I asked was that adding the nameservers from a pc that uses dhcp, to resolv.conf on my server, which uses static addresses (defined in /etc/network/interfaces), considerably sped up DNS lookup. I wondered if there was a quick way to check that the nameservers I had added still were the current ones. I'll settle with booting knoppix when in doubt, and comparing the manually added entries in my server's resolv.conf to the entries in knoppix's automatically generated resolv.conf.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.