Skip to content

Instantly share code, notes, and snippets.

View edwardselby's full-sized avatar
🎯
Focusing

Edward Selby edwardselby

🎯
Focusing
View GitHub Profile
@sparkcodeuk
sparkcodeuk / floating-ip-gateway.sh
Created March 2, 2018 21:47
Digital Ocean floating IP gateway script (force droplet to use the assigned floating IP for outbound traffic as well as inbound traffic)
#!/bin/bash
# Force outbound traffic through the attached floating IP
NET_INT="eth0"
CURL_TIMEOUT=3
echo -n "Setting floating IP as the default gateway: "
# Check there's a floating IP attached to this droplet
if [ "$(curl -s --connect-timeout $CURL_TIMEOUT http://169.254.169.254/metadata/v1/floating_ip/ipv4/active)" != "true" ]; then