Created
March 14, 2016 12:33
-
-
Save eagafonov/5c57bfbe353a9c93a94c to your computer and use it in GitHub Desktop.
[DigitalOcean] Simple script to route outgoing traffic through Floating IP
This file contains 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 -x | |
set -e | |
# https://www.digitalocean.com/community/tutorials/how-to-use-floating-ips-on-digitalocean | |
DESTINATION_IP=$1 | |
shift || (echo "E: Destination IP is not provided. Aborting"; exit 1) | |
ANCHOR_GW=$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/anchor_ipv4/gateway) | |
route del $DESTINATION_IP || true | |
route add $DESTINATION_IP gw $ANCHOR_GW |
Hi and thanks for the script!
Where do you suggest to put it? I tried running it at launch with rc.local
but it seems that sometimes network interfaces restarts automatically and so the script should be run again.
Thanks again.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what this exactly doing can you tell?