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

Domain/hostname based routing?

Scheduled Pinned Locked Moved Routing and Multi WAN
5 Posts 2 Posters 3.4k 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.
  • E
    Ender117
    last edited by Ender117 Jun 25, 2018, 11:12 PM Jun 25, 2018, 11:11 PM

    I have been researching how to route specific traffic differently, ex. route traffic to certain sites through VPN. The obvious solution was that you set a FQDN alias and do PBR for that alias. That's not real domain/hostname based routing and relies on IP being the same between alias update and a client actually request the site. It might work well for smaller sites but not for larger sites with large pools of IPs.

    Since domain/hostname is at L7, I think we need some proxy involved. Here is what I have in mind:

    A WAN and a VPN interface, a LAN1 and LAN2 interface. Proxy1 listen to LAN1 and Proxy2 listen to LAN2, both as transparent proxy. All client computer connects on LAN1.

    Proxy1 filters specific traffic containing the domain/hostname in question and forward them to Proxy2, process the rest of the traffics itself. Proxy2 just work like normal proxy.

    Have PBR setup to guide traffic from LAN1 to WAN and LAN2 to VPN. Done

    I believe at least squid can be setup like this: https://www.rootusers.com/configure-squid-proxy-to-forward-to-a-parent-proxy/. Perhaps it's something beyond the scope of WebGUI but still feasible.

    The biggest problem I see here is pfSense can only apply firewall rules (thus PBR) on inbound traffic, so once it gets to the proxy it cannot be re-directed. However I read that floating rules can work around this restriction. If not, I think one can always move Proxy2 to a dedicated server connecting to LAN2 and be done with it.

    Last but not least, this would only work with HTTP, so only solve part of the problem. Not sure if squid or other proxies can work with HTTPs and/or other protocols, but HTTP is what we see most anyway. Nowadays more and more traffic are HTTPs just for the sake of it so this might be a problem. If the proxy can still see the URLs itself (should be or how it can be routed normally?) then this should still work. Nevertheless, one can at least deploy proxies as man-in-the-middle for HTTPs, which shouldn't be a big problem as long as you own both the client and the proxy.

    So, what are your thoughts on this? Do you think I am on the right track?

    K 1 Reply Last reply Jun 26, 2018, 8:25 AM Reply Quote 0
    • K
      kpa @Ender117
      last edited by Jun 26, 2018, 8:25 AM

      @ender117 said in Domain/hostname based routing?:

      The biggest problem I see here is pfSense can only apply firewall rules (thus PBR) on inbound traffic, so once it gets to the proxy it cannot be re-directed. However I read that floating rules can work around this restriction. If not, I think one can always move Proxy2 to a dedicated server connecting to LAN2 and be done with it.

      Floating rules can't solve this problem, they are equally unable to redirect traffic that has already entered the system. The limitation is in FreeBSD's own implementation of the PF packet filter and it prevents policy based routing on traffic that is going out on an interface.

      E 1 Reply Last reply Jun 26, 2018, 3:09 PM Reply Quote 0
      • E
        Ender117 @kpa
        last edited by Jun 26, 2018, 3:09 PM

        @kpa said in Domain/hostname based routing?:

        @ender117 said in Domain/hostname based routing?:

        The biggest problem I see here is pfSense can only apply firewall rules (thus PBR) on inbound traffic, so once it gets to the proxy it cannot be re-directed. However I read that floating rules can work around this restriction. If not, I think one can always move Proxy2 to a dedicated server connecting to LAN2 and be done with it.

        Floating rules can't solve this problem, they are equally unable to redirect traffic that has already entered the system. The limitation is in FreeBSD's own implementation of the PF packet filter and it prevents policy based routing on traffic that is going out on an interface.

        That's what I heard as well. But according to pfsense document:

        Floating Rules can:

        Filter traffic from the firewall itself
        Filter traffic in the outbound direction (all other tabs are Inbound processing only)
        Apply rules to multiple interfaces
        Apply filtering in a “last match wins” way rather than “first match wins” (quick)
        Apply traffic shaping to match traffic but not affect it’s pass/block action
        Much more.

        https://www.netgate.com/docs/pfsense/firewall/floating-rules.html

        I cannot see any other way to understand the first 2 points

        1 Reply Last reply Reply Quote 0
        • K
          kpa
          last edited by Jun 26, 2018, 3:18 PM

          All correct but the document makes no mention of policy based routing on the outgoing direction which is not possible in pfSense, normal rules or floating rules. PBR on the inbound direction works just fine with floating rules just like it does with normal rules.

          E 1 Reply Last reply Jun 26, 2018, 3:28 PM Reply Quote 0
          • E
            Ender117 @kpa
            last edited by Ender117 Jun 26, 2018, 3:29 PM Jun 26, 2018, 3:28 PM

            @kpa said in Domain/hostname based routing?:

            All correct but the document makes no mention of policy based routing on the outgoing direction which is not possible in pfSense, normal rules or floating rules. PBR on the inbound direction works just fine with floating rules just like it does with normal rules.

            Oh I just assume that PBR is just a firewall action like pass/drop so if you can apply firewall you can PBR. Looks like things are a bit more complex.

            Anyway if Proxy2 is setup on a dedicate VM instead of pfsense then it should work? It might be a bit too complicated though.

            1 Reply Last reply Reply Quote 0
            1 out of 5
            • First post
              1/5
              Last post
            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
              This community forum collects and processes your personal information.
              consent.not_received