Version 1 (modified by bro, 10 years ago) (diff)

Added first section about FreeBSD

Setting up Deluge with VPN

  1. FreeBSD
    1. Multiple routing tables

There are two basic options when using VPN.

  1. Use the VPN as the primary connection with default routing passing through the VPN. This way all the traffic uses the VPN.
  2. Use the VPN connection only for specific traffic. All network traffic passes through the default interface except for the traffic you specifically want to route through the VPN interface.

FreeBSD

Multiple routing tables

FreeBSD supports multiple routing tables in the kernel, which enables a process to be started with a custom default routing table.

With an alternate routing table already set up (on -1) you can start Deluge daemon with:

 $ setfib -1 /path/to/deluged -l /var/log/deluged/deluged.log  -L info -i <insert-VPN-IP>

Using openvpn you can set up the alternate routing table automatically:

  1. Create /usr/local/etc/openvpn/link-up.sh with the following content:
    #!/bin/sh
    IP=`/sbin/ifconfig $1 | grep "inet " | cut -d" " -f4`
    echo "LINK-UP - SETTING AS DEFAULT GATEWAY FOR ROUTING TABLE 1: $IP"
    /usr/sbin/setfib -1 /sbin/route add default $IP
    
  1. Add the following line to the vpn config file
    up "/usr/local/etc/openvpn/link-up.sh tun0"
    
    where tun0 is the VPN interface.

When starting openvpn the alternate routing table should be set up

$ /usr/local/etc/rc.d/openvpn start