PFsense: How to bypass a VPN connection for a single ip
This time I want to show you something, that I think many peoples have already had a need for once in a while.
I am using a VPN provider, I am sure alot of you do as well, it's a pretty neat service, you connect to them, and they root all your traffic through their VPN.
But what if you wanted to have a certain ip, maybe a server, like a mail server, not being routed through that VPN but rather connect to other mail servers directly.
This becomes especially problematic since some VPN services actually block smtp tcp ports, and some mail servers do block connections from VPN services.
I have found alot of tutorials on the web about different ways on how to do this, from using a relay server, over adding multiple ips and routes. These are good tips, but I wanted something simple.
I am running pfsense as my main firewall and gateway to the internet, and I have a static ip setup, basically what many small businesses have too. And in pfsense its just adding two additional rules of sorts.
Things you need to have for this to work:
- a static ip, this is important, as the times that dynamic ips where able to send email out are long gone.
- a VPN connection configured in your pfsense as an openvpn client.
- a machine/container you want to exclude from your vpn bubble, for whatever reason…
- pfsense in a current version (I just haven't tested in older versions, I always run the current stable everywhere, eases the task of administrating things)
so, let's begin:
under Firewall -> Rules -> LAN, edit the rule that forwards all your data through the VPN, so that it looks like this:
and secondly, add a new rule under Firewall -> Rules -> LAN, where you let that server ip pass through the Standard Gateway explicitly, this rule should look like that:
Adding the passthrough rule to pfsense for the server
Finally click on save, click on apply, and thats it.
You can now test your servers external ip with a tool like lynx or telnet to your favorite mail server and see if it lets you in;-)
I hope this short tutorial was once again helpful to some of you, my readers, and i am looking forward on your input, what small tricks you got that make your life easy with pfsense? Hope to hear from you.