0

Possible Duplicate:
Can I get the names of all the domains a Linux computer is connected to in C++?

Hi

My Linux machine is connected (by external NICs) to 2 external domains. I want to discover in my linux c++ application all the names of domains my machine is connected to. how can I get all these names?

BTW: if getnameinfo can do it - it doesn't work for me. please suggest another answer.

PLEASE ATTACH CODE EXAMPLE

10x!

Community
  • 1
  • 1
gln
  • 1,011
  • 5
  • 31
  • 61
  • Machines aren't connected to domain names. Not sure exactly what you're after. Maybe just grab all local IPs, and resolve each? – derobert Jan 17 '11 at 09:02
  • derobert - how can I resolve each IP to domain name - that's my question. – gln Jan 17 '11 at 09:20

1 Answers1

0

You can get a list of domains the DNS resolver is going to search from /etc/resolv.conf

$ cat /etc/resolv.conf 
# Generated by NetworkManager
search anon.local int.anon.co.uk
nameserver 10.201.13.10
nameserver 10.213.13.10
nameserver 8.8.8.8

In the above there is search directive with a list of domains to search. So, when you try to resolve hostname X, it is going to search for X, X.anon.local and X.int.anon.co.uk.

Maxim Egorushkin
  • 131,725
  • 17
  • 180
  • 271