Since the previous answer is clutter, I will put another one with workflow, just by using AWS CLI (you can write fine tune automation script using AWS SDK) (http://docs.aws.amazon.com/cli/latest/userguide/installing.html)
- Create ENI with private IP using. (aws ec2 create-network-interface) Write down ENI id
- Allocate EIP for VPC. (aws ec2 allocate-address --domain vpc) write down EIP-id
- Link EIP to ENI-id, point to correct private IP (aws ec2 associate-address)
- Create or launch EC2 instance, attach to the ENI. (aws ec2 attach-network-interface)
Once you put everything script in place, recreate the EC2 instance with the proper ENI is just matter of minutes.
(Updated answer below)
In Linux, to assign multiple IP address to an interface, the correct assignment to the interface is to add additional ip address to the physical interface. For ubuntu , etc, it is something like eth0:0 , eth0:1, for 1st interface, eth1:0, eth1:1 for subsequent interface.
And this is slightly different for Centos, ie.
enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether ....
inet 192.168.1.150/24 brd 192.168.1.255 scope global enp0s3
inet 192.168.1.151/24 brd 192.168.1.255 scope global secondary enp0s3
inet 192.168.1.152/24 brd 192.168.1.255 scope global secondary enp0s3
So the correct documentation should be this one.
http://www.unixmen.com/linux-basics-assign-multiple-ip-addresses-single-network-interface-card-centos-7/
In short, Centos will automatically create one network-interface file for each interface. Just go /etc/sysconfig/network-scripts/ and check each file name as ifcfg-eth* (don't ask me why the above link show enp0) . The tricky part is whether your Centos enforce to use NetworkManager, and you must configure as required by the centos documentation wiki.centos.org/FAQ/CentOS7
So you should see least 4 interface file for your m3.xlarge , e.g.
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth1
/etc/sysconfig/network-scripts/ifcfg-eth2
/etc/sysconfig/network-scripts/ifcfg-eth3
Since the main interface should be running, it will give you the hint of the running instance IP address. So if you open /etc/sysconfig/network-scripts/ifcfg-eth0, if the instance configure as IP 10.0.1.10, you should see this
IPADDR0="10.0.1.10"
To add more IP address, just do as unixmen link say, i.e.
IPADDR1="10.0.1.97"
IPADDR2="10.0.1.98"
IPADDR3="10.0.1.99"
Then open ifcfg-eth1, ifcfg-eth2, ifcfg-eth3 and do repeat the task. After done that, use "systemctl restart network" to restart. (backup all config file so you just override the file in the future)
Next , you play with the routing part. Just print out your VPC route table, Subnet. Now inside /etc/sysconfig/network-scripts/, you deal with route-ethX , i.e. route-eth0, route-eth1, route-eth2,route-eth3. That's mean, you must know your own network to configure this part (which should be shown in your VPC layout). Since you mentioned only one VPC gateway 10.0.1.1, so for all route-* file, it should be something like this
# I just assume your put all your 10.0.1.x in the CIDR /24 segments
#
# file route-eth0
# Assume your first ENI IP address is 10.0.1.10
# format : default via gateway-ip dev dev-name table route-table-number
default via 10.0.1.1 dev eth0 table 0
# format : network cidr dev dev-name src ENI-intrace-IP route-table-number
10.0.1.0/24 dev eth0 src 10.0.1.10 table 0
# file route-eth1
# Assume your 2nd ENI IP address is 10.0.1.11
default via 10.0.1.1 dev eth1 table 1
10.0.1.0/24 dev eth1 src 10.0.1.15 table 1
# file route-eth2
# Assume your 2nd ENI IP address is 10.0.1.12
default via 10.0.1.1 dev eth1 table 2
10.0.1.0/24 dev eth2 src 10.0.1.12 table 2
Then you follow the document you mentioned instruction, in /etc/sysconfig/network-scripts, create a rule-ethX , i.e. rule-eth0, rule-eth1
1. Increment the table number to match route-ethX
2. Change the IP to the assigned internal network address of the ENI.
# file rule-eth0 ,but as the doc suggest, you should skip this file.
# format : from ENI_IP/CIDR table <table_number>
from 10.0.1.10/32 table 0
#file rule-eth1
from 10.0.1.11/32 table 1
You should play the Centos network setup with your Local Vmware/virtualbox virtual network adapter. Then you don't need to worry a sudden