Running hostname -A reports two host names: an incorrect one that doesn't even resolve to my server and a correct one.

$ hostname -A
notmyhostname.notmydomain.com  myhostname.mydomain.com

The incorrect one is messing up other tools like xauth. I grep -r'ed /etc to try to find where this value is stored, but I can't find it.

Where are these stored and how can I fix the first hostname value?


The extra hostname comes from a DNS .in-addr.arpa IP address lookup (often called 'reverse DNS', that maps IP addresses to hostnames). Or perhaps /etc/hosts.

From man hostname:

-A, --all-fqdns

Displays all FQDNs of the machine. This option enumerates all configured network addresses on all configured network interfaces, and translates them to DNS domain names. Addresses that cannot be translated (i.e. because they do not have an appropriate reverse IP entry) are skipped. Note that different addresses may resolve to the same name, therefore the output may contain duplicate entries. Do not make any assumptions about the order of the output.

Note especially the phrase This option enumerates all configured network addresses on all configured network interfaces

So, to find out where notmyhostname.notmydomain.com is coming from, generate a list of all IP addresses on all interfaces, and do a reverse-DNS lookup on each of them:

ip addr | awk '/inet/ {gsub(/\/.*/,"") ; print $2}' | xargs -n 1 host

This will do lookups for ipv6 as well as ipv4 addresses. If you want only ipv4, add a space after 'inet', e.g.

awk '/inet / ...' ...

BTW, most likely it's your ISP or hosting provider (or their upstream) or whoever owns the .in-addr.arpa or .ip6.arpa domain for your IP subnet. They will have added a reverse-DNS entry for your IP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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