Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a server on amazon which normally runs like a champ; after increasing the instance size this weekend, then decreasing it back down to its normal size, I've started to get odd errors every time I run a command under sudo. Here's an example:

sudo ps -ef
sudo: unable to resolve host domU-##-##-##-##-##-##

Where # is a number. Its important to note the command then executes as expected. I thought there might be something bound oddly in my hosts file so I had a look at that:

127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

And it seems pretty normal although I don't know enough to be sure. Can anyone shed some light on this repeating error and how to go about fixing it?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

Ensure that your hostname is in /etc/hostname. To see what is in there now, you can either run hostname -f or cat /etc/hostname.

When you move your EC2 instances around, you lose your hostname so it no longer matches the hostname at the time you installed Ubuntu.

share|improve this answer
    
Okay, the /etc/hostname file has the host in the error - so that makes sense. Can I put a generic value in there or will it need to be changed everytime I move my EC2 instance? (this has to be done weekly). –  ESW Sep 26 '11 at 16:56
    
You should be able to set this automatically with a little script. Something like: echo 'hostname -a' > /etc/hostname in your /etc/rc.local file should set the hostname correctly at each boot. You may have to play with the syntax a bit, but that's the gist of it. –  jdw Sep 27 '11 at 12:22
add comment

It seems that you are not using the correct Amazon DNS.

If your EC2 instance is in the VPC 172.31.0.0, the DNS you should use is 172.31.0.2. So you have to "add two" to the last number.

Only the DNS of your VPC will respond to your local hostname ip-XXX-XXX-XXX-XXX.

From the documentation:

The string AmazonProvidedDNS maps to a DNS server running on a reserved IP address at the base of the VPC network range "plus two". For example, the DNS Server on a 10.0.0.0/16 network is located at 10.0.0.2.

http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_DHCP_Options.html#AmazonDNS

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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