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

    Setup specific traffic through VPN

    Scheduled Pinned Locked Moved General pfSense Questions
    4 Posts 3 Posters 3.2k 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.
    • ?
      A Former User
      last edited by

      Hi all,

      I would like to set up my vpn client in pfsense so that when I want to access a specific IP, then pfsense routes this via a vpn server that my pfsense can log into. This means that not all traffic goes through the vpn connection, but rather a specific address or set of addresses, and everything else does not go through VPN. For example, I want to set up pfsense vpn client so that when I connect to https://www.whatismyip.com/ then it shows the vpn server's IP I am connecting to, and everything else, eg https://whatismyipaddress.com/ shows my actual IP.

      Is this possible? and if so, how can I do this in pfsense?

      I have followed the instructions for setting up openvpn client from https://protonvpn.com/support/pfsense-vpn-setup/ and https://nordvpn.com/tutorials/pfsense/pfsense-openvpn/ but I get stuck at the point of setting up NAT because the common thing is to route all traffic via vpn rather than only for one or two specific IP's.

      Any help would be much appreciated.

      Many thanks!

      1 Reply Last reply Reply Quote 0
      • KOMK
        KOM
        last edited by

        You use firewall rules on the LAN interface to determine which gateway the traffic goes to.

        1 Reply Last reply Reply Quote 0
        • V
          viragomann
          last edited by

          Go to the OpenVPN client settings and check "Don't pull routes".

          Add a firewall rule for the IP you want to route over the VPN. Put that IP into the destination box, you may also restrict that rule to a specific source IP. Open the advanced options, go down to the gateway option and select the VPN gateway. Put that rule to the top of your LAN rule set.
          To route the traffic to multiple IPs over the VPN you may put all these into an alias and then use the alias as destination in the rule.

          1 Reply Last reply Reply Quote 0
          • ?
            A Former User
            last edited by

            That's great. Thank you very much. I'll give that a try and let you know how it goes.

            Many thanks

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