I am trying to point a fully qualified domain name "example.com" to an external host such as Amazon ELB "site-xxxxxx.us-west-1.elb.amazonaws.com" using HOSTALIASES environment variable and it's not working.

example.com  site-xxxxxx.us-west-1.elb.amazonaws.com

However, when I use a different alias such as "example site-xxxxxx.us-west-1.elb.amazonaws.com". The example correctly resolves.

example site-xxxxxx.us-west-1.elb.amazonaws.com

My Question is can I use a fully qualified domain name "example.com" as an alias pointing to another public domain using HOSTALIASES? If not then what are the other options?


It looks like you can NOT use FQDN hostnames in the first entry:

"If the name consists of a single component, that is, contains no dot, and if the environment variable HOSTALIASES is set to the name of a file, that file is searched for any string matching the input hostname."

Quoted: http://man7.org/linux/man-pages/man7/hostname.7.html

It is not described WHAT the behavior is if you use FQDN as first entry in HOSTALIASES, but there seems to be a restriction and you can only use non domain qualified hostnames


Your best bet is to use AWS PRIVATE hosted zones with a root record and associate them to the VPC. What @Fermin said here is true. FQDNs are not supported by the flow that uses HOSTALIASES only subdomains like localhost and ip-172-27-192-207 are supported. A good example of THAT subdomain mapping is posted here. But like I said, that won't work. You have to use DNS.


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.