Setup specific traffic through VPN



  • 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!



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



  • 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.



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

    Many thanks


Log in to reply