I want to emulate the Amazon EC2 metadata service on my local system for testing. In EC2, this runs on I understand that this is the designated range for pseudorandom local addresses on DHCP failure, but Amazon in their wisdom are also using it for this purpose, so I need to do the same thing.

I'm using F19 Alpha. In earlier Fedora, I could simply make a virtual interface on the loopback device, like lo:0 and assign that a static address using the normal ifcfg- scripts. Now, that fails with "Error: Connection activation failed: Device not managed by NetworkManager or unavailable".

(I'm running NetworkManager, but previously I was doing this underneath it.)

Is finding some way to continue what I was doing with lo:0 the right approach (and if so, how?), or is there a better way?

  • Couldn't you do this with netfilter/iptables? Like NAT back to
    – goldilocks
    Apr 26, 2013 at 20:26
  • @goldilocks why fake it when you can do it for real? ;)
    – Tim
    Apr 26, 2013 at 20:59

2 Answers 2


To answer your specific question, you can use iproute2 to assign the IP address like this:

sudo ip addr add dev lo

It will just add a new IP to the interface, no need for aliasing with :0, :1, etc. Note this is going to be lost after a reboot.

And to quickly emulate the metadata service you can use netcat like this:

while true; do sudo nc -l 80 <<< '"region" : "eu-west-1"'; test $? != 0 && break; done

This will give you the region when asking like this:

curl -s

NOTE: According to the current version of this documentation page from AWS the metadata service IP is a link-local address and it points to the Wikipedia article about it. In turn that page points to RFC3927 where it reads:

The IPv4 prefix 169.254/16 is registered with the IANA for this purpose.

  • 1
    Shouldn't this be /16? I just saw at serverfault.com/questions/427018/… references that say it's a 16-bit network and should not be subnetted.
    – Tom Hundt
    Oct 1, 2019 at 22:03
  • Thanks for the tip @TomHundt, I've updated the reply. There's no way to know for sure if AWS is following the RFC, as they technically could do something different, but I'm using the documentation as reference to assume they are. Thanks again! Feb 3, 2020 at 22:54

Haven't used Fedora in a while, but it should still be very similar to CentOS. I did this on CentOS 6.

Copy /etc/sysconfig/network-scripts/ifcfg-lo to /etc/sysconfig/network-scripts/ifcfg-lo:1

Your new config should look like so:


Restart the network service service network restart.

Bonne chance mon ami !

  • Unfortunately, this is exactly what I was doing and what was working but now isn't.
    – mattdm
    Apr 28, 2013 at 14:32
  • 1
    As I said above, shouldn't this be a /16 network (so, netmask
    – Tom Hundt
    Oct 1, 2019 at 22:03

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.