LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 12-07-2008, 09:54 AM   #1
NorwegianBlue
LQ Newbie
 
Registered: Aug 2006
Posts: 8

Rep: Reputation: 0
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.
 
Old 12-07-2008, 10:52 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Slackware current
Posts: 8,460

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
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#
 
Old 12-07-2008, 10:53 AM   #3
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Slackware current
Posts: 8,460

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
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#
 
Old 12-07-2008, 11:00 AM   #4
x_terminat_or_3
Member
 
Registered: Mar 2007
Location: Plymouth, UK
Distribution: Fedora Core, RHEL, Arch
Posts: 341

Rep: Reputation: 34
That's not quite what the OP asks for.

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.

Look on this page for more information: http://en.wikipedia.org/wiki/DHCP

Best regards
 
Old 12-07-2008, 11:40 AM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 21,599
Blog Entries: 47

Rep: Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413
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?..
 
Old 12-07-2008, 11:59 AM   #6
x_terminat_or_3
Member
 
Registered: Mar 2007
Location: Plymouth, UK
Distribution: Fedora Core, RHEL, Arch
Posts: 341

Rep: Reputation: 34
Code:
dig NS `host $(lynx -dump whatismyip.org) | awk '{ print $5}'`
Quote:
; <<>> DiG 9.5.0-P2 <<>> NS xxx-xxx-xxx-xxx.cable.ubr11.newt.blueyonder.co.uk.
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43570
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;xxx-xxx-xxx-xxx.cable.ubr11.newt.blueyonder.co.uk. IN NS

;; AUTHORITY SECTION:
cable.ubr11.newt.blueyonder.co.uk. 10592 IN SOA ns.blueyonder.co.uk. hostmaster.blueyonder.co.uk. 2008012716 14400 7200 864000 28800

;; Query time: 2 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sun Dec 7 17:55:29 2008
;; MSG SIZE rcvd: 114
It does not give me the domain name or IP address of my resolver.
 
Old 12-07-2008, 12:40 PM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 21,599
Blog Entries: 47

Rep: Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413Reputation: 1413
Quote:
Originally Posted by x_terminat_or_3 View Post
It does not give me the domain name or IP address of my resolver.
What would ns.blueyonder.co.uk's purpose be, then?
 
Old 12-07-2008, 01:04 PM   #8
x_terminat_or_3
Member
 
Registered: Mar 2007
Location: Plymouth, UK
Distribution: Fedora Core, RHEL, Arch
Posts: 341

Rep: Reputation: 34
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.
 
Old 12-07-2008, 02:55 PM   #9
NorwegianBlue
LQ Newbie
 
Registered: Aug 2006
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks so far,

Just to be clear, what I'm looking for is something like this:

myname@mymachine:~$ the_command_i'm_looking_for
nameserver 193.213.112.4
nameserver 130.67.15.198
nameserver 130.67.60.68
 
Old 12-07-2008, 03:07 PM   #10
x_terminat_or_3
Member
 
Registered: Mar 2007
Location: Plymouth, UK
Distribution: Fedora Core, RHEL, Arch
Posts: 341

Rep: Reputation: 34
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.
 
Old 12-07-2008, 03:07 PM   #11
x_terminat_or_3
Member
 
Registered: Mar 2007
Location: Plymouth, UK
Distribution: Fedora Core, RHEL, Arch
Posts: 341

Rep: Reputation: 34
You're not on about

Code:
cat /etc/resolv.conf
Are you?
 
Old 12-07-2008, 03:29 PM   #12
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,136

Rep: Reputation: 106Reputation: 106
Quote:
Originally Posted by NorwegianBlue View Post
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.
 
Old 12-09-2008, 12:49 PM   #13
NorwegianBlue
LQ Newbie
 
Registered: Aug 2006
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks

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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set DNS servers? How to stop auto change of DNS servers? newtovanilla Linux - Newbie 1 10-29-2008 09:19 PM
How to determine vacant IP addresses rozilla Linux - Networking 6 07-30-2008 01:27 AM
How do you determine how many IP addresses, which should be private and how to instal Cannan2468 Linux - Server 6 02-22-2008 09:09 AM
setting up ISP's DNS server for fetchmail nivedhitha Red Hat 0 02-06-2007 08:06 AM
RH8.0 can't use ISP's DNS through DHCP over DSL behind NetGear sobRegReqd Linux - Networking 5 12-16-2002 09:27 PM


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

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration