LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 08-11-2019, 03:29 PM   #1
Ulysses_
Senior Member
 
Registered: Jul 2009
Posts: 1,303

Rep: Reputation: 57
Round robin load balancing to three proxies listening on ports 1001, 1002, 1003


Got three HTTP/S proxies listening on ports 1001, 1002 and 1003 on 192.168.0.1. On another system on the same network, firefox is set to use the 192.168.0.1:1001 proxy. Is it possible with iptables or otherwise in the server system, to use all proxies in a round robin fashion?

Inspired from this nice article but we want to round robin connections, not to send packets in a round robin fashion. As in, the first connection gets the HTML code of a web page using the 1001 proxy, the next connection gets an image using the 1002 proxy and so on.

Last edited by Ulysses_; 08-11-2019 at 04:36 PM.
 
Old 08-11-2019, 03:47 PM   #2
Ulysses_
Senior Member
 
Registered: Jul 2009
Posts: 1,303

Original Poster
Rep: Reputation: 57
Or does the article round robin connections? And therefore the following is what is needed?

iptables -A PREROUTING -t nat -p tcp -d 192.168.0.1 --dport 1001 \
-m statistic --mode nth --every 3 --packet 0 \
-j DNAT --to-destination 192.168.0.1:1001

iptables -A PREROUTING -t nat -p tcp -d 192.168.0.1 --dport 1001 \
-m statistic --mode nth --every 2 --packet 0 \
-j DNAT --to-destination 192.168.0.1:1002

iptables -A PREROUTING -t nat -p tcp -d 192.168.0.1 --dport 1001 \
-j DNAT --to-destination 192.168.0.1:1003

Last edited by Ulysses_; 08-11-2019 at 03:56 PM.
 
Old 08-11-2019, 04:10 PM   #3
Ulysses_
Senior Member
 
Registered: Jul 2009
Posts: 1,303

Original Poster
Rep: Reputation: 57
Or is "ip route" the way to do it (after adding virtual nic's eth1, eth2 and eth3 on both systems and respective virtual cables and static IP's), ie doing this on the client:

ip route add default scope global \
nexthop via 192.168.1.1 dev eth1 weight 1 \
nexthop via 192.168.2.1 dev eth2 weight 1 \
nexthop via 192.168.3.1 dev eth3 weight 1

and on the server:

iptables -A PREROUTING -t nat -p tcp -i eth1 --dport 1001 \
-j DNAT --to-destination 192.168.0.1:1001

iptables -A PREROUTING -t nat -p tcp -i eth2 --dport 1001 \
-j DNAT --to-destination 192.168.0.1:1002

iptables -A PREROUTING -t nat -p tcp -i eth3 --dport 1001 \
-j DNAT --to-destination 192.168.0.1:1003

Can this be simplified somehow?

Last edited by Ulysses_; 08-12-2019 at 01:46 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi-WAN setup not load balancing / no round robin (iptables, ip routes, ip rules) robopt Linux - Networking 0 07-03-2013 03:44 AM
SFTP/load-balancing/round robin help. Jsy Linux - Networking 5 12-22-2009 08:23 PM
Round robin load balancing problem. GuitsBoy Linux - Networking 0 05-03-2004 09:20 AM
Network Load Balancing & DNS round robin scooby snacks Linux - Networking 1 04-19-2004 12:28 PM
PS2 mouse goes crazy [it goes round n round n round...] goci Linux - Hardware 2 10-09-2003 08:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration