Send all traffic through single IP

Posted July 29, 2014 5.3k views

I need to use one of the droplets as a public ip that all backend scripts (on other droplets) connect through so the client can open one ip on their firewall but I can farm out the work to various servers.

droplet1/public IP droplet 2 connects private->droplet1->outbound to internet.

Is this possible and or easy to do in any way? Basically share a single outbound IP

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.

Submit an Answer
4 answers

I don t understand very well the question, bit i think you need pat+nat. With nat you can share outbound your public ip (all machine behind tour router have the same IP outgoing.) pat you can translate port incoming

If you want to direct all traffic through the one machine, set it allow ip.forwarding and then set routes on them to use the one server as the gateway for certain destinations. You will have to adjust firewalls to match.

Without know more about your actual use case, it’s hard to get more specific. Here are some tutorials that should point you in the right direction. These show you how to set up private networking and isolate a server:

How To Set Up And Use DigitalOcean Private Networking

How To Isolate Servers Within A Private Network Using IPTables

After that, it really depends on how you need the servers to communicate. If you simply want to pass HTTP requests onto the droplet on the private network, you might want to look into using Nginx as a simple “load balancer.”

by Etel Sverdlov
This article covers how to set up a simple load balancer on a DigitalOcean droplet with nginx. The tutorial covers setting up a round robin loadbalancer that can then direct site visitors to one of a set of IPs

You will need to route traffic through the IP you want to see as external, then perform NAT on that droplet.

It’d be much easier to ask the company to have the common sense of whitelisting the IPs you give them instead of forcing you to rework your entire network on their whim.

EDIT: There are obviously other ways to accomplish this, but we have no details about what you’re trying to do. A proxy could maybe work, for instance.