Skip to contentSkip to conversation

Problem for Bittorrent Application behind Linux Firewall

DISCUSSION Tom 3 participants 3 messages Sep 23, 2003 – Oct 3, 2003

lore
Share & tools
lore

Tom

author
#0 lore raw

Hello Everyone:

I have encountered a problem when implementing my Linux Firewall using iptables together with some applications like Bittorrent.It's peer to peer application sharing program.My Linux have two network interfaces, one is connecting to my internal LAN with IP range 192.168.1.0/24 and other network interface is connecting to internet via ADSL modem using PPPoE.

Before I illustrated my situation to you, I have tried to use "BT client" called Bittorrent S-5.7.3(Shadow's Experimental) to download file from the others. It has no problem for download but the light turns "YELLOW" to indicate that I'm behind firewall.Then I add some rules to my iptables to allow traffic can pass via in my machines in LAN from outside.

The following is my iptables rules.According to my understanding, BT use the ports 6881 to 6889,Then I forward these ports to my machines in LAN.

#! /bin/sh
iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 6881:6889 -j DNAT --to 192.168.1.90:6881-6889 iptables -A FORWARD -p tcp -s 192.168.1.90 --dport 6881:6889 -j ACCEPT

After I have implemented these rules, my light for BT client turns to "GREEN" mean that it's operational.Then I try to make some BT file for someone to download behind firewall, but problem occurs. The light is always "RED" - there are no connections from other clients.

So I would like to know that what happens to my linux firewall and how can I do to achieve my goal that creating BT files behind firewall for others to download ?

The above chain rules already prove that outside traffic can come in to my client machine.

I appreciate if anyone can help me to solve these problems...many thx !!

Tom Cheung
23 Sept 2003

#1 lore raw
Quoted 6 lines · Tom

Hello Everyone:

#! /bin/sh
iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 6881:6889 -j DNAT --to 192.168.1.90:6881-6889
iptables -A FORWARD -p tcp -s 192.168.1.90 --dport 6881:6889 -j ACCEPT

If someone comes from external network, i.e Internet, you have to authorize packet to your machine :
-d 192.168.1.90 and not -s !

BR,

Signature · 2 lines
Eric Leblond
Nufw, Now User Filtering Works (http://www.nufw.org)
#2 lore raw
In reply to Tom
Quoted 3 lines · Tom

The following is my iptables rules.According to my understanding, BT use the ports 6881 to 6889,Then I forward these ports to my machines in LAN.

I have no idea about bittorrent and it's protocol, sorry.

Quoted 5 lines

#! /bin/sh
iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 6881:6889 -j DNAT --to 192.168.1.90:6881-6889 iptables -A FORWARD -p tcp -s 192.168.1.90 --dport 6881:6889 -j ACCEPT

Those rules say 'nat any port between 6881:6889 to any port between 6881:6889'. i.e. port 6881 can be NAT'ed to 6884, happening in a non-deterministic manner.

try 9 seperate rules for every port if you want to have that guarantee.

Quoted 2 lines

Tom Cheung
23 Sept 2003

Signature · 5 lines
- Harald Welte <[email protected]>             http://www.netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie