Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm working on a network analysis tool (academic research), and I would like to find out what DNS is used on the machine the software is running on. I'm not a network admin, and I'm wondering: what's the easiest way to find that out; across platforms (that is, on each Linux, Mac and Windows), and preferably using something that's accessible in Python?

Usually, systems seem to conveniently hide this stuff from the user -- I can set a fixed DNS, or I can use my router's settings via DHCP, or ... I'm sure there are other systems too (LDAP?). So just looking at resolv.conf may not always lead to the right answer -- or does it?

Many thanks!

share|improve this question

closed as off topic by SvW, womble, Shane Madden, Chris S, Iain Aug 11 '11 at 18:43

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

    
mind explaining the downvote? wrong forum? –  sebastian_k Aug 11 '11 at 18:02
    
oh, and the downvote was probably because this isn't the right forum. probably stack overflow. –  Michael Lowman Aug 11 '11 at 18:17
    
Hm, I wasn't sure, since I was more interested in the network side of things than in the implementation. I thought sysadmins would know this kind of stuff. I'll live with it :) –  sebastian_k Aug 11 '11 at 18:19
    
Define "what DNS", for a start -- do you mean the upstream recursive resolver's IP address(es)? –  womble Aug 11 '11 at 18:29
    
Yes, I mean those. As you can tell, I'm not even sure what's the right terminology for the different resolving services. I'll change the question's title. –  sebastian_k Aug 11 '11 at 18:34

2 Answers 2

up vote 4 down vote accepted

If you're on Linux, resolv.conf does cut it. Just for DNS, though. The other methods of resolving hosts are not associated with DNS. Check out your system's nsswitch.conf for more information.

FYI, auto-DHCP config works by automatically editing resolv.conf.

As for OS X, I don't use em enough. I believe that sort of thing gets stored in some binary databases which replace the local files but really don't know.

For Windows, I believe a netsh interface ip show dns does what you want. Windows also uses name resolution mechanisms other than DNS: network broadcasts are especially annoying.

share|improve this answer
    
nsswitch.conf ... that's the kind of pointer I was looking for. Thanks for your help! –  sebastian_k Aug 11 '11 at 18:23

This is probably in the wrong section but I'm going to bite anyways since it hasn't been moved.

This python code should get you want you want to know. I'm not sure what operating system it's been tested on so you might have to tweak it.

http://osdir.com/ml/python.tutor/2002-06/msg00473.html

Linux and OSX will use resolv.conf

Windows will store it's in the registry.

share|improve this answer
    
I'd seen this, but thanks still! –  sebastian_k Aug 11 '11 at 18:22

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