LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   downloading bittorrent using a vpn connection (https://www.linuxquestions.org/questions/linux-networking-3/downloading-bittorrent-using-a-vpn-connection-729530/)

0zon3 05-30-2009 12:34 PM

downloading bittorrent using a vpn connection
 
I recently built a new linux box running ubuntu 9.04 on an Asus eeebox. So far everything works great, but I am having an issue setting up my iptables rules. What I am trying to do is only allow bittorrent traffic over my vpn connection ppp0. I have created a rule to drop all bittorrent traffic over eth0 and allow all bittorrent traffic over ppp0. Currently my script is not blocking the eth0 connection, so I am still able to download over eth0. My goal is to hide my ISP's ip address and only show the VPN ip address when I am using bittorrent. Here is my iptables script. I hope someone can look at it a tell me what I have done wrong or what I am missing. Thanks in advance for all the help.

Code:

#!/bin/bash

# Remove all rules and chains
iptables -F
iptables -X

# first set the default behaviour => accept connections
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT

# Allow ESTABLISHED and RELATED incoming connection
iptables -A INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow loopback traffic
iptables -A INPUT -i lo -j ACCEPT
# DROP all forward packets, I don't share this internet connection
iptables -A FORWARD -j DROP
# Drop all Bittorrent packets going over eth0
iptables -A OUTPUT -o eth0 -p tcp -m multiport --dport 6881:6999 -j DROP
# Allow all Bittorent traffic going over vpn connection pp0
iptables -A OUTPUT -o ppp0 -p tcp -m multiport --dport 6881:6999 -j ACCEPT

# End message
echo " [iptables rules are set]"


unSpawn 06-07-2009 10:35 AM

Iptables rules work in a "first match wins" way. If something does not work the best thing is to intersperse your ruleset with "-j LOG" rules for debugging. That way it will be easier to find out what's hitting the bit bucket. BTW Bittorrent can use TCP as well as UDP.


All times are GMT -5. The time now is 02:18 PM.