Cloud platforms - sudo: cannot resolve host

I use linux for my cloud servers on Amazon-EC2 and openstack. When trying to run:

sudo chhown ubuntu somepath 

I get this error from time to time:

sudo: cannot resolve the host

Most of the answers to this question on the Internet are to edit the / etc / hosts file.

However, I deploy my servers automatically. furthermore, I am not going to use "localhost", but rather my AWS public DNS:

 ssh -i mykey.pem ubuntu@ec2-12-34-56-78.eu-central-1.compute.amazonaws.com 

Therefore, I can’t just trivially insert localhost, not to mention that my IP address may change after I reset my machine. (Do not want to "waste" your precious floating IP addresses for each server)

In addition, I deploy dozens of servers at a time, so I cannot afford the manual step of editing a text file. Is there an automatic fix for this problem? I recently started using openstack, and the problem is there too.

+7
ubuntu amazon-ec2 openstack sudo
source share
2 answers

EC2 instances within VPCs will correctly resolve their automatically assigned internal host names only if you configure VPCs correctly. You need:

 DNS hostnames: yes DNS resolution: yes 

http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-dns.html

+24
source share

To solve this problem, I ran the following commands:

 sudo vi /etc/hosts 

Then in the opened hosts file add:

 127.0.0.1 10.0.30.150 

Obviously, the address 10.0.30.150 will be the host IP address in the warning message.

+3
source share

All Articles