0

I've got a setup like:

          |<-->|---> server 1 <---|
clients <-|                        <--> proxy <--> 
          |<-->|---> server 2 <---|

Hope my ASCII art works :)

On my proxy I would like to be able to route back via the server, the original packet came from.

Right now I can make static rules like:

ip rule add from 10.0.0.0/10 table back_to_server
ip route add default via server1-IP-ADDRESS dev eth0 back_to_server

But I have to hardcode the server1-IP-ADDRESS.

Is it possible to have this dynamic, so it will use the IP address, or mac-address, from where it last saw a packet come from?

Alfred Balle
  • 409
  • 3
  • 9
  • 22
  • Are your servers in the same subnet? Please edit your question to include the proxy configuration. – Ron Trunk Sep 24 '20 at 11:57
  • Hi Ron, they are in the same subnet, yes. The proxy configuration is pretty much what I wrote, it's not a traditional proxy. – Alfred Balle Sep 24 '20 at 19:08
  • Impossible to tell without knowing more about your proxy. In theory yes, but it depends on the capabilities of the proxy. – Ron Trunk Sep 24 '20 at 20:12
  • The proxy is simply the Linux OS - currently routing via ip routes and ip rules. Nothing more. – Alfred Balle Sep 25 '20 at 06:35
  • It's the Linux OS I want to have dynamic routing, via ex. ip routes/rules or iptables or nftables or similar. – Alfred Balle Sep 25 '20 at 06:36
  • Are you setting up a simple NAT router? Either NAT-ing source (if initial connection comes from "left") or destination (if initial traffic comes from "right")? It's not clear if the server is actually the client or the back-end. – A.B Sep 25 '20 at 06:39
  • We are not NAT'ing source. But traffic are entering from either server 1 or server 2, and when proxy send traffic back, it HAS to sent the packets to the server from where it original received traffic from. And this can change. So one day traffic may come from server 1, and then proxy has to route traffic back to server 1, and next day it might be server 2 where traffic is coming from, and then traffic must be routed back to server 2. It can change multiple times during the day. – Alfred Balle Sep 25 '20 at 06:54
  • I've updated the ASCII. So clients attach to either server 1 or server 2. And this can change during a day. – Alfred Balle Sep 25 '20 at 06:57

0 Answers0