3

I've been messing around with getaddrinfo and getnameinfo but the closest I got to useful output was "localhost.localdomain". I'm not sure what to pass in for the "node" or "service" args of getaddrinfo, although I think it's the function I want.

karenc
  • 267
  • 1
  • 3
  • 11
  • 3
    You cannot, with any kind of reliability, convert "localhost" into a fully qualified domain. There might, for example, be several fully qualified domains which use the same IP address, or there might be none. If, in your specific case, you *know* there is a unique fully qualified domain, then just specify it in your app via a config file. In your case, it appears localhost.localdomain IS the fully qualified domain, as configured in /etc/hosts – user229044 Jan 28 '10 at 17:14

2 Answers2

2

Actually, Zxaos's answer here is pretty much the answer I was looking for (even though it's for C and mine was for C++, it works in both):

How do I find the current machine's full hostname in C (hostname and domain information)?

So I guess my question was a duplicate...

Community
  • 1
  • 1
karenc
  • 267
  • 1
  • 3
  • 11
0

You can try the following command:

#hostname --fqdn

Works well with OpenSuse flavour. Not sure about Ubuntu.

James A Mohler
  • 11,060
  • 15
  • 46
  • 72