You are not logged in.

#1 2014-05-07 07:36:22

man0riaX
Banned
Registered: 2014-05-05
Posts: 11

VPN: Only route one program through VPN

Hello,

I have set up my Raspberry Pi as a VPN server so that I can access my CalDav and CardDav server that run on it from anywhere I go. The thing is, to sync my calendars and contacts, I have to enable my VPN. I want, however, surf through the internet using my ethernet or WLAN connection at the time without the traffic being routed through the VPN.

Is there any way I can do that? Have the VPN connection enabled at all times and being able to surf the net without having the traffic flow through the VPN any only have the thunderbird calendar and contacts sync through the VPN?

Thanks!

Phil

Offline

#2 2014-05-07 09:26:35

HiImTye
Member
From: Halifax, NS, Canada
Registered: 2012-05-09
Posts: 1,072

Re: VPN: Only route one program through VPN

you could use iptables to accomplish this

gateway="your router's default gateway ip"
interface="your network interface name, i.e. enp3s0"
portRange="the list of ports you want to send to your VPN, i.e. 80,443 or 1023:1033"

ip route add default table 100 via "$gateway"
ip rule add fwmark 1 table 100
ip route flush cache
iptables -t mangle -I PREROUTING -i "$interface" -p tcp -m multiport --dport ! "$portRange" -j MARK --set-mark 1

fill in the top stuff, change --dport to --sport if you want it to be the source port instead of the destination port, viola!

Offline

Board footer

Powered by FluxBB