Skip Navigation

You are here: Home > Projects > Articles > Routing UTorrent Trafic Over A VPN

Routing UTorrent Trafic Over A VPN

Last modified: July 28, 2012

Introduction

Situation: You would like to automatically route trafic from uTorrent over a vpn, leaving all other trafic undisturbed. Perhaps your ISP uses deep packet inspection to shape torrent trafic and you need to download a Linux ISO or some media from www.legaltorrents.com.

You will need: a Windows 7 client, a Linux VPN PPTP server, and a Mikrotik router.

Disclaimer: I am not responsible for your actions; make sure to have full tested backups before beginning; if something breaks, you keep both pieces.

Windows 7 client

Follow these steps to change the TCP/IP protocol settings to manually add two IP addresses for your Ethernet adapter.

  1. From Control Panel select "Network and Internet", "Network and Sharing Center", "Change Adapter Settings".
  2. Double click on the appropriate network connection, such as "Local Area Connection".
  3. Activate the "Details" button.
  4. Make note of the IPV4 Address, IPV4 Subnet Mask, IPV4 Default Gateway, and IPV4 DNS Server(s).
  5. Activate the Close button.
  6. Activate the Properties button.
  7. From the items list, select "Internet Protocol Version 4 (TCP/IPV4)", then activate the Properties button.
  8. Activate the Advanced button.
  9. On the "IP Settings" tab, add two IP addresses based on the IPV4 Address and IPV4 Subnet Mask that you noted earlier. For example if the IPV4 address was 192.168.88.250 and the IPV4 Subnet Mask was 255.255.255.0, you might add one IPV4 Address of 192.168.88.81 with IPV4 Subnet Mask 255.255.255.0 and another IPV4 Address of 192.168.88.82 with IPV4 Subnet Mask 255.255.255.0.
  10. On the "IP Settings" tab, add the default gateway that you noted earlier.
  11. On the DNS tab, add the dns server(s) that you noted earlier.
  12. Activate the OK button.
  13. Activate the OK button.
  14. Activate the Close button.
  15. Activate the Close button.
  16. You may need to disable and re-enable the Network Connection. If so, right-click the connection and select Disable, then activate the network connection to enable it.

uTorrent

Follow these steps to set up uTorrent to bind to the second IP address that you set up previously.

  1. From within uTorrent, select the Options menu, then select the Preferences item.
  2. in the tree of options, Select the Advanced item.
  3. In the Advanced Options list, select the net.bind_ip setting, set it to the second IP address that you used earlier, then activate the Set button.
  4. In the Advanced Options list, select the net.outgoing_ip setting, set it to the second IP address that you used earlier, then activate the Set button.
  5. Activate the OK button to close the Preferences dialog.

Linux PPTP VPN Server

Consult the howto here: http://poptop.sourceforge.net/dox/debian-howto.phtml. Create a PPTP VPN connection having a user vpn_user with password vpn_password.

Mikrotik Router

In this section we will: add an interface for the PPTP VPN client which connects to the PPTP VPN server , add a firewall rule to masquerade trafic destined for that interface, and route trafic from the IP address used by uTorrent through the PPTP VPN client interface.

The following placeholders are used and have the provided meanings.

[admin@MikroTik]> /interface pptp-client
[admin@MikroTik] /interface pptp-client> add add-default-route=no allow=mschap2 connect-to=vpn_server_IP dial-on-demand=yes disabled=no \
name=pptp_interface_name password=vpn_password profile=default-encryption user=vpn_user
[admin@MikroTik] /interface pptp-client> /ip firewall nat
[admin@MikroTik] /ip firewall nat> add action=masquerade chain=srcnat disabled=no out-interface=pptp_interface_name
[admin@MikroTik] /ip firewall nat> /ip firewall mangle
[admin@MikroTik] add action=mark-routing chain=prerouting disabled=no new-routing-mark=second_ip passthrough=yes src-address=second_ip_address
[admin@MikroTik] /ip firewall mangle> /ip route
[admin@MikroTik] /ip route> add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=pptp_interface_name routing-mark=second_ip
[admin@MikroTik] /ip route>

Conclusion

You could easily adapt the preceding to solve a number of problems such as routing all trafic from a virtual machine with a static IP address over a VPN.

If you have any comments or questions, please contact me.