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

    How to port forward to a specific host (without WG as the default route)

    Scheduled Pinned Locked Moved WireGuard
    13 Posts 2 Posters 1.1k 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.
    • Bob.DigB
      Bob.Dig LAYER 8 @Molski
      last edited by

      @molski You need a firewall rule for that too, at least there is none linked to that NAT Rule directly.

      MolskiM 1 Reply Last reply Reply Quote 0
      • MolskiM
        Molski @Bob.Dig
        last edited by

        @bob-dig This rule is what implements the policy based route to even make it work it through the VPN in the first place. That works fine.

        pf-rules.png

        Bob.DigB 2 Replies Last reply Reply Quote 0
        • Bob.DigB
          Bob.Dig LAYER 8 @Molski
          last edited by Bob.Dig

          @molski Delete everything there! You should treat it like WAN, there shouldn't be anything other then the port you opened.

          1 Reply Last reply Reply Quote 0
          • Bob.DigB
            Bob.Dig LAYER 8 @Molski
            last edited by

            @molski I also set the Interface Group Membership to none in VPN-WireGuard-Setting.

            MolskiM 1 Reply Last reply Reply Quote 0
            • MolskiM
              Molski @Bob.Dig
              last edited by

              @bob-dig said in How to port forward to a specific host (without WG as the default route):

              I also set the Interface Group Membership to none in VPN-WireGuard-Setting.

              I tried that first, and had that working fairly quickly when I was routing my entire LAN through the VPN. It was only until I was experimenting with routing certain hosts, where I could not get it to work at all that way.

              I was watching Christian McDonald's YouTube videos which gave me other ideas to try. (Who is the I believe is the main developer of the WG package, and and then got hired by Netgate.) He creates an interface group for the VPN gateways (for fail over purposes). But I thought I'd try that for a single VPN gateway, and surprisingly, it worked! But not until I assigned it to an interface.

              @bob-dig said in How to port forward to a specific host (without WG as the default route):

              Delete everything there! You should treat it like WAN, there shouldn't be anything other then the port you opened.

              Actually thinking back, those rules don't change anything. That's just left overs of me trying a hundred or so combinations of things.

              Bob.DigB 1 Reply Last reply Reply Quote 0
              • Bob.DigB
                Bob.Dig LAYER 8 @Molski
                last edited by

                @molski said in How to port forward to a specific host (without WG as the default route):

                Actually thinking back, those rules don't change anything. That's just left overs of me trying a hundred or so combinations of things.

                Yup, the only thing there should be the one port you like to forward. So just activate it in the NAT-Rule and it will be there.

                MolskiM 1 Reply Last reply Reply Quote 0
                • MolskiM
                  Molski @Bob.Dig
                  last edited by Molski

                  That was the first thing I tried. Even redoing it so it makes that exact same rule, but with the gateway as "*". It still gets the same result:

                  $ curl https://ipv4.am.i.mullvad.net/port/57995
                  {"ip":"XX.XX.XX.XX","port":57995,"reachable":false}
                  

                  Edit: This all works in the normal use case of routing the entire LAN. (And yes the port is open and can connect through the VPN).

                  Bob.DigB 1 Reply Last reply Reply Quote 0
                  • Bob.DigB
                    Bob.Dig LAYER 8 @Molski
                    last edited by

                    @molski said in How to port forward to a specific host (without WG as the default route):

                    Edit: This all works in the normal use case of routing the entire LAN. (And yes the port is open and can connect through the VPN).

                    I don't think this is the normal use case to route everything through the VPN.
                    Show the VPN Interface again, this time with only one rule and no gateway set in there.
                    Also show the outbound NAT Rules.

                    MolskiM 1 Reply Last reply Reply Quote 0
                    • MolskiM
                      Molski @Bob.Dig
                      last edited by Molski

                      @bob-dig said in How to port forward to a specific host (without WG as the default route):

                      I don't think this is the normal use case to route everything through the VPN.

                      That was a bad way to phrase it. I've done a lot with VPNs and even some pfSense through work, and tying networks together and whatnot. But I've never singled out specific hosts on a subnet, and treated them differently (routing-wise anyway). I was meaning this was not a common scenario (or secure), at least in my experience.

                      @bob-dig said in How to port forward to a specific host (without WG as the default route):

                      Show the VPN Interface again, this time with only one rule and no gateway set in there.
                      Also show the outbound NAT Rules.

                      I could not get this working at all until I set the gateway there, for my VPN interface I had to put this:

                      pf-tmp.png

                      Setting that gateway and this NAT rule made everything all work for a specific host. Both were needed.

                      pf-tmp2.png

                      That host uses the VPN, and everything else doesn't. It's great! Just the port forwarding doesn't.

                      Bob.DigB 1 Reply Last reply Reply Quote 0
                      • Bob.DigB
                        Bob.Dig LAYER 8 @Molski
                        last edited by Bob.Dig

                        @molski You are doing things your own way which is fine, if you know what you are doing, but I have my doubts. It looks to be more trial and error on your side.

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