Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the most reliable and simple way to detect, from within the host, that it's running in EC2 ?

The goal is to apply some changes on boot and move some of the things in the /mnt partition (because of disk space). Because it happens directly after the OS image has been instantiated there isn't a lot of software installed (eg: curl is missing on the Ubuntu AMIs).

share|improve this question
Why would you not know you are running on EC2 in the first place? – EEAA Jul 25 '13 at 21:48
rDNS the IP address... – Nathan C Jul 25 '13 at 21:48
@NathanC - that doesn't work in a VPCed instance. – EEAA Jul 25 '13 at 21:49
@EEAA True, but that wasn't mentioned. – Nathan C Jul 25 '13 at 22:23
Thanks guys. @EEAA: If you ship an install script you don't know where it's going to execute. It's not an end-goal but detecting EC2 is still useful in some cases. – zimbatm Jul 26 '13 at 17:37

After looking into chef's ohai code, I can see that they use two checks: the existence of a http server on and the existence of fe:ff:ff:ff:ff:ff in the arp table.

This can be simulated like that:

arp | grep fe:ff:ff:ff:ff:ff && wget -t 1 -T 2 -S --spider
share|improve this answer
It should be noted that is also available in EC2-alike infrastructures like Eucalyptus, not just EC2 proper. – ceejayoz Jul 25 '13 at 22:02

Your Answer


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.