-1

My scenario:

I would like to setup a HTTP proxy server in a Linux VM using node.js.

It will only accept whitelisted inbound traffic, and route it to external services.

I assigned 4 public IP to the VM NIC as 4 different IP configurations.

However, all outbound traffic from this VM still uses the primary IP, never uses the other 3.

How do I route outbound traffic to each IP randomly/round robin?

I am also open is using other OS/Services to achieve this goal.

Thank you!

Tony
  • 425
  • 1
  • 5
  • 12

3 Answers3

0

I found this to work.

const rndInt = Math.floor(Math.random() * 4) + 1
if (rndInt == 1) text = 1;
if (rndInt == 2) text = 2;
if (rndInt == 3) text = 3;
if (rndInt == 4) text = 4; 
    alert(text);

Example on a website using tags - https://altify-chs.netlify.app/html/proxychoose

Altify
  • 9
  • 3
  • 19
  • Thanks but I am not trying to do it from application level, but wish to do it from the OS level such that all my application calls are identical, but can use a different outbound IP – Tony Mar 12 '22 at 04:45
0

Generally operating systems wont load balance between multiple outbound IP's as they select the "best" IP to send your traffic with.

Your application will need to bind all 4 IP's and randomize what IP is used for outbound requests.

Nisd
  • 1,068
  • 9
  • 19
0

Spent a bit more time today and found that the best solution for me is to setup a NAT gateway in the same subnet of the VM.

Then bind multiple public IPs to this NAT Gateway. Then outbound access from the VM uses these public IPs randomly.

Tony
  • 425
  • 1
  • 5
  • 12