In this scenario we will have an ec2 instance with:
* 3 network interfaces
* 3 public IPs (one for each interface)
* 3 different process with different public outbound address running in separate network namespaces
As starting point, we have a simple ec2 instance with one interface and a public IP assigned to it. The steps are:
– Allocate two new elastic IPs
– Create two new network interfaces in the same subnet in which resides the instance.
– Associate the new elastic IPs to these new network interfaces.
– Associate the new network interfaces to the instance. Now, it have the default eth0 and two more, eth1 and eth2.
– Create a pair of network namespaces for the new interfaces:
ip netns add blue
ip link set eth1 netns blue
ip netns add green
ip link set eth2 netns green
– Request the IPs for the interfaces:
ip netns exec blue dhclient eth1
ip netns exec green dhclient eth2
– And test it:
ip netns exec blue curl ipinfo.io/ip
ip netns exec green curl ipinfo.io/ip
Take into account that:
– You need to launch the proces with the “ip netns exec xxxx” due that systemd don’t support the network namespace assignement.
– Look the limits of AWS, by default, only 5 EIPs are allowed and each type of instance have a network limit.