Report this

What is the reason for this report?

Floating iP gateway as default router and source address for outbound connections

Posted on October 31, 2015

Community!

I am curious if it is possible to setup anchor ip gateway as default router so all outbound traffic from droplet shows to external services as coming from floating ip.

This will greatly simplify my external system firewall setup since floating ip never changes; I can allow all connections from floating ip.

I tried adding the anchor ip gateway as the defaultrouter in /etc/rc.conf and reboot but this did not work. (curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/anchor_ipv4/gateway)

I am using freebsd, but welcome any linux recommendations as well. There may be multiple ways to achieve this (e.g. routes, routed, iptables), but what is the CLEANEST approach, and is this even possible on Digital Ocean?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

You can also get IP address using this ip addr show eth0 | awk '/inet .*\/16/ {print $2}' | cut -d/ -f 1 without querying API.

To not blocking Digital Ocean’s monitoring agent (do-agent ), exclude the metadata API from the redirect rules:

# iptables -t nat -A POSTROUTING -p tcp  -o eth0 ! -d 169.254.169.254 -j SNAT --to-source $ANCHOR_IP

Thanks, this was pretty impressive if you face any problem regarding then head over to 192.168.0.1

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.