Set fully qualified domain name on EC2 instance

I am trying to set a fully qualified domain name on EC2 instance. I have set CNAME entry in Route53, so when I go to sync1.staging1.mycompany.net, it resolves to the correct instance.

What I have done so far without success, I have edited /etc/hostname (so it stays the same after restarting):

sync1.staging1.mycompany.net

I have then used hostname command to set the hostname:

sudo hostname sync1.staging1.mycompany.net

I have then edited /etc/hosts and made sure this line is there:

127.0.0.1 localhost sync1.staging1.mycompany.net sync1

The problem is, when I run hostname -f, I get:

localhost

When I run hostname -s, I get correctly:

sync1

When I run just hostname without parameters, I get:

sync1.staging1.mycompany.net sync1

The problem is I am trying to run a Puppet manifests which needs the fully qualified domain name to be set, otherwise I am getting an error when I run puppet apply manifests/site.pp:

Error: Could not find default node or by name with 'sync1.eu-west-1.compute.internal, sync1.eu-west-1.compute, sync1.eu-west-1, sync1' on node sync1.eu-west-1.compute.internal
Error: Could not find default node or by name with 'sync1.eu-west-1.compute.internal, sync1.eu-west-1.compute, sync1.eu-west-1, sync1' on node sync1.eu-west-1.compute.internal

This is EC2 instance running on Ubuntu 12.04 LTS.

Any ideas? Do I need to set and elastic IP address for the instance in order for it to have the fully qualified domain name?

1 Answer

hostname -f will return the first name after 127.0.0.1

So simply switching localhost and your fqdn will give you a correct return address while the localhost alias will still work.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like