Home > Enterprise >  Azure VM/Services - Using multiple outbound public IP randomly
Azure VM/Services - Using multiple outbound public IP randomly

Time:03-12

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!

CodePudding user response:

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

CodePudding user response:

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.

CodePudding user response:

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.

  • Related