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

I am trying to associate a secondary internal IP with my Amazon VPC small machine, I am using a Ubuntu based image with AMI ID:ami-6936fb00. Problem is that I am unable to figure out how to configure my OS(Ubuntu) to record the second private IP address ( this is required as mentioned in the AWS Docs: http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/using-instance-addressing.html#using-instance-addressing-eips)!

I have single ENI and have associated one extra private IP with it.

Any help would be appreciated.

Thanks

share|improve this question
    
Are you talking about EC2? AWS VPC is a completely different thing (more VPN/networkish stuff) –  number5 Jul 27 '12 at 6:51
1  
I believe Multiple IPs are possible in VPC only. –  APZ Jul 27 '12 at 11:45

2 Answers 2

up vote 4 down vote accepted

Your /etc/network/interfaces file probably has something like the following:

auto eth0
iface eth0 inet static
    address 192.0.2.10
    netmask 255.255.255.0
    gateway 192.168.2.1

This is what assigns the primary IP (it may also be DHCP). To assign a secondary IP add a post-up script to attach an additional address to eth0.

auto eth0
iface eth0 inet static
    address 192.0.2.10
    netmask 255.255.255.0
    gateway 192.168.2.1
    up ip addr add 192.168.2.20/24 dev eth0
share|improve this answer
    
Thanks for the reply, can you please tell me how is your solution better than mine, I am not a guru in networking and want to understand which approach is better. –  APZ Jul 27 '12 at 11:46
1  
@APZ Aliased interfaces (i.e. eth0:0) are a hack created by ifconfig in order to support multiple IP addresses. They are considered deprecated however, and iproute2 (i.e. the ip command) should be used instead to attach multiple IPs to a single interface, which is what my solution does. –  mgorven Jul 27 '12 at 16:52
    
@mgorven Could you please explain the "20/24" part? Also, I am trying to add 4 IP addresses to two ENI's (for a total of 8 IPs). I can do it in the Amazon Linux AMI no problem (since Amazon gives you instructions in their documentation), but do you think this approach would work for that? Thanks! –  chaimp Aug 31 '12 at 3:09
    
@jeffp The IP is 192.168.2.20; the /24 specifies the subnet mask, i.e. 24 bits make up the network part and 32-24=8 bits make up the host part. If you have a specific question you should ask a question though. –  mgorven Aug 31 '12 at 7:11

I was finally able to figure out how to record second private IP for my AWS VPC machine: I appended this to /etc/network/interfaces:

auto eth0:0
iface eth0:0 inet static
    address 192.x.y.z
    netmask 255.255.255.0

and then running ifup eth0:0

My ifconfig showed both eth0 and eth0:0 with correct private IPs.

share|improve this answer

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.