Created
December 22, 2016 16:54
-
-
Save emrahgunduz/a2bb1d03ed73d37aac9c0f13144f9f03 to your computer and use it in GitHub Desktop.
Add multiple public ips to ec2 instance route
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#add routes for secondary IP addresses | |
MAC_ADDR=$(ifconfig eth0 | sed -n 's/.*ether \([a-f0-9:]*\).*/\1/p') | |
IP=($(curl http://169.254.169.254/latest/meta-data/network/interfaces/macs/$MAC_ADDR/local-ipv4s)) | |
for ip in ${IP[@]:1}; do | |
echo "Adding IP: $ip" | |
ip addr add dev eth0 $ip/20 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment