Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Is 'lan only' load balancer/relayd possible?

    Scheduled Pinned Locked Moved pfSense Packages
    5 Posts 2 Posters 2.5k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      hcoin
      last edited by

      So either I'm missing something dead obvious or hit a bug in load-balancer/relayd.

      I have a service that runs on several nodes on the lan.  The service is not http, but just an unencrypted, single session, vanilla tcp service.  I can 'telnet <lan node=""><port>' and have the correct conversation from each of the nodes.

      My project is to have the load balancer create a virtual ip on the lan, then distribute/redirect calls from other nodes on the lan to the virtual ip to whichever of the servernodes on the lan that's up.

      Seems simple enough.  But try as I might I can't telnet to the virtual IP on the lan mentioned on the load balancer.  I even created a virtual CARP ip on the lan with the named address and restarted relayd – didn't work.  I tried to set the load balancer IP to localhost/127.0.0.1 then 'nat' the request on the lan to that -- no telnet connect.

      Tried DNS and TCP on the load balancer setting-- same answer.

      Any clues?</port></lan>

      1 Reply Last reply Reply Quote 0
      • H
        hcoin
        last edited by

        So, I did a netstat and also an fstat -p on relayd:  There's some serious bug in the pfsense load balancer.  My choice in the load balancer is 'tcp' and the os reports its only opened udp datagram streams.  Something is far wrong.  Latest stable pfsense build.

        1 Reply Last reply Reply Quote 0
        • H
          hcoin
          last edited by

          Result:  When the load to be balanced goes in and out the same interface, relayd has to be used in the 'relay' mode and not 'redirect' mode.  Moreover, 'load balancing' only really works in the 'relay mode', as implemented what's going on is more 'round robining' than 'load balancing'.

          pfsense does not appear to support the 'relay' mode of relayd.

          1 Reply Last reply Reply Quote 0
          • jimpJ
            jimp Rebel Alliance Developer Netgate
            last edited by

            To do that, the clients and servers must be in different subnets, or you need outbound NAT to translate the traffic so it appears to come from the firewall itself.

            The problem is this:

            Client A -> request -> VIP -> relayd -> Server B

            Server B sees Client A's original IP, and shortcuts the response:

            Server B -> respond -> Client A

            Client A drops the traffic because the response does not match the request (Server B's IP != the VIP)

            Switch to manual outbound NAT, add a rule to NAT from the LAN subnet to your server IPs, translating to the Interface address, and then save/apply. It should work that way. The NAT will cause the traffic to flow back via the firewall.

            Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

            Need help fast? Netgate Global Support!

            Do not Chat/PM for help!

            1 Reply Last reply Reply Quote 1
            • H
              hcoin
              last edited by

              On the one hand, 9 / 10 on the hack-o-meter.  On the other hand, never argue with success.  Thanks!

              1. It would be good to add "check script …" to the possible monitors.

              2. It would be good to warn of the aforementioned should the 'forward to' and the 'monitor address' be on the same subnet.

              3. It would be good to warn if the virtual address isn't among the addresses this system arps for.  I'm assuming that if the address is a carp vip in backup mode the system won't advertise via the load balancer facility that it owns the virtual ip.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.