[Lxc-users] "hostname --fqdn" returns just an error message

Matthijs Kooijman matthijs at stdin.nl
Mon May 7 16:01:09 UTC 2012


Hi Harald,

> Running "hostname --fqdn" in an lxc client returns an error
> message on stderr and an empty string on stdout:
hostname --fqdn basically does a name lookup on whatever "hostname"
returns (I think it does a forward lookup on the short hostname and then
does a reverse lookup on the result to get the fqdn, but I'm not 100%
sure). It is up to you to make sure that it actually returns something.

On most systems (like your host, probably), this is done by including a
line in /etc/hosts, like:

127.0.1.1       grubby.stderr.nl grubby

The line above is added by a recent Debian installer, I think a more
traditional line is:

127.0.0.1       grubby.stderr.nl grubby localhost

An alternative is to make sure that you configure the right search
domain in /etc/resolv.conf, such that resolving your plain hostname
actually works.

Another alternative is to configure the fqdn as the short hostname,
(e.g., lxc.utsname = grubby.stderr.nl), but I'm not 100% sure if that's
really a robust solution (I'm using it nonetheless, so I don't need to
hardcode the hostname in /etc/hosts, just in the lxc configuration, and
because I use the .local avahi domain for the fqdn which doesn't play
well as the DNS search domain).

Gr.

Matthijs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20120507/eac7d367/attachment.pgp>


More information about the lxc-users mailing list