Skip to content

Instantly share code, notes, and snippets.

@plasticbrain
Last active May 3, 2021 19:28
Show Gist options
  • Select an option

  • Save plasticbrain/49b07885914129150f16 to your computer and use it in GitHub Desktop.

Select an option

Save plasticbrain/49b07885914129150f16 to your computer and use it in GitHub Desktop.
AWS - EC2 - Assign Multiple IPs to the Same Instance
1. Assign a secondary private ip to the instance
- Select the instance, then choose Actions > Mange Private IP Addresses
- In the Manage Private IP Addresses dialog box, Click "Assign new IP"
- Enter a specific IP address that's within the subnet range for the instance (or just leave the field blank to have it choose one for you)
- (Optional) Select Allow reassignment to allow the secondary private IP address to be reassigned if it is already assigned to another network interface.
- Click Yes, Update, and then click Close.
2. Add the new IP to the instance's network interface.
- SSH into the instance
- $ sudo ip addr add new.ip.address.here/20 dev eth0
- Test to make sure the ip is listed:
- $ ip addr list dev eth0
Note: If you ever need to remove the new IP use:
$ sudo ip addr del new.ip.address.here/20 dev eth0
3. Assign an Elastic IP to your new private IP
- In the AWS Console, choose "Elastic IPs"
- Select an available IP and choose "Associate Address"
- Choose the instance, and *importantly*, in the Private IP section, be sure to select the NEW private ip you just created.
Click "Associate"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment