on Amazon EC2 I want to set up multiple IPs on secondary Network Interface.
whatever I do it sometimes fail to connect to secondary IPs, main word here is sometimes, thats why its very complicated to pinpoint whats the issue...
here is my current setup:
EC2: m5.large
Ubuntu 18.04 - so using netplan.
1st Network interface eth0 has 1 private and 1 elastic IP, it works all the time, no issues there.
eth0 setup:
root@multi-ip-host:/etc/netplan# cat 50-cloud-init.yaml
network:
version: 2
ethernets:
eth0:
dhcp4: true
match:
macaddress: 02:19:c1:0c:e8:a0
set-name: eth0
also private IP for the eth0 is: 10.20.0.45
2nd - ens6 has multiple IPs set up like this:
root@multi-ip-host:/etc/netplan# cat 51-ens6.yaml
network:
version: 2
renderer: networkd
ethernets:
ens6:
addresses:
- 10.20.0.11/20
- 10.20.0.198/20
- 10.20.0.22/20
dhcp4: no
routes:
- to: 0.0.0.0/0
via: 10.20.0.1 # Default gateway
table: 1000
- to: 10.20.0.11
via: 0.0.0.0
scope: link
table: 1000
- to: 10.20.0.198
via: 0.0.0.0
scope: link
table: 1000
- to: 10.20.0.22
via: 0.0.0.0
scope: link
table: 1000
routing-policy:
- from: 10.20.0.11
table: 1000
- from: 10.20.0.198
table: 1000
- from: 10.20.0.22
table: 1000
each of the private IPs have elastic IPs attached. The issue is, that after set up, there may be 0 or more IPs that I can connect to. Then after reboot, there may be different IP that I can connect to from the 2nd interface, but cant connect to others.
What I am doing wrong?
UPDATE: I have added more static IPs to the eth0 and they all work 100% of the time.
On ens6 left only 1 IP - and it seems its working 50% of the time...
each time after running netplan apply I have approximately 50% chance to connect to that secondary Interface's IP from my machine. I do no other changes on aws, so to limit and narrow down possibilities on what can be wrong.
I can understand that if I do an error in the script it should either work or not 100%, but thats not the case here.
Is there anything fundamentally wrong how I set up ens6 in this script?