TorrentFlux.com Welcome, Guest. Please login or register.
03-21-2010, 20:56:23
Home Help Search Login Register donate
TorrentFlux Home | TorrentFlux Hosting

+  TorrentFlux Forums
|-+  Code Hacks and Tools
| |-+  TorrentFlux 2.1 Hacks
| | |-+  Blocking Clients with IPTables, but how ?
« previous next »
Pages: [1] Go Down Print
Author Topic: Blocking Clients with IPTables, but how ?  (Read 2253 times)
TommyD
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 49




View Profile
« on: 06-30-2006, 16:10:38 »

I red a lot of documents about firewalling with iptables but i cannot find a working solution for it. Quiet simple .. I have a TorrentFlux client and i wanna block all connecting clients except 1 (just for testing) :

Code:
/sbin/iptables -P INPUT DROP
/sbin/iptables -P OUTPUT ACCEPT

/sbin/iptables -F INPUT
/sbin/iptables -F OUTPUT

/sbin/iptables -A INPUT -p udp -s na.me.ser.ver/32 --source-port 53 -d 0/0 -j ACCEPT

/sbin/iptables -A INPUT -s all.owed.clie.nt -j ACCEPT
/sbin/iptables -A INPUT -d blo.ck.every.thing  -j DROP

I was think about something above .. But it isnt really working .. I tried somethings with the above script and SSH ... And yes that works but it looks like torrent clients are not doing what ssh does.

The idea simple .. Block every incoming client (iptables -A INPUT -d blo.ck.every.thing  -j DROP), and just allow one of them (iptables -A INPUT -s all.owed.clie.nt -j ACCEPT) ...

Can anyone tell me how to solve this ??
Logged
Paczesiowa
Full Member
***
Offline Offline

TF Base: Linux 2.x
Posts: 177



View Profile
« Reply #1 on: 06-30-2006, 16:37:11 »

/sbin/iptables -A INPUT -d blo.ck.every.thing  -j DROP
this doesnt make sense... why do u use "-d=--destination" in INPUT? it's obvious that if packet is in INPUT chain it's destination is ur computer... this should work with "-s" though...

but it's not enough... with something like this u wont be able to contact tracker...
Logged

TommyD
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 49




View Profile
« Reply #2 on: 06-30-2006, 16:58:28 »

/sbin/iptables -A INPUT -d blo.ck.every.thing  -j DROP

This is ment like : Block all incoming connection to the <ipaddress> of that server / client. (Where the Torrent Client is running). But this is not what it does ??

What i want, i think quiet easy, is something like :

1. Drop all incoming connections.
2. Allow <this> or <that> ipaddress.

Do you have an idea of how to get this thing working ??
« Last Edit: 06-30-2006, 17:00:39 by TommyD » Logged
Paczesiowa
Full Member
***
Offline Offline

TF Base: Linux 2.x
Posts: 177



View Profile
« Reply #3 on: 06-30-2006, 17:54:26 »

u cannot block packets TO his ip in INPUT chain...every packet in INPUT chain is destinated to u... packets TO his ip are inside OUTPUT so they are accepted anyway. to do this u should in INPUT accept packets FROM (source) his ip and FROM (tracker) or use rule that accepts established and related conections.
Logged

TommyD
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 49




View Profile
« Reply #4 on: 06-30-2006, 18:41:55 »

You mean something like this ?

Code:
#!/bin/sh

# Flush tables
iptables -F
iptables -X

# Block every incoming request
/sbin/iptables -P INPUT DROP

/sbin/iptables -I STATE -m state --state ESTABLISHED,RELATED -j ACCEPT

# For BT Clients
/sbin/iptables -A INPUT -p tcp -s <ip of outside client> -d <ip of my bt client> --dport 49152:49153 -j ACCEPT

# Lets keep SSH available ;-)
/sbin/iptables -A INPUT -s <ip of pc @ home> -d <ip of server> --dport 49152:49153 -j ACCEPT

When i want to add an new client to accept i can just copy this line then ??
/sbin/iptables -A INPUT -p tcp -s <ip of outside client> -d <ip of my bt client> --dport 49152:49153 -j ACCEPT

And just do a /blabla/iptables to reload firewall rules ?

Does it work like that ??

Because i am not using any firewall for outgoing packets i dont think i need something for the way back i guess ... Am i right about that ?

(I am sorry i am really a N00B about this kind of things .. And about a lot else too ;-) )
« Last Edit: 06-30-2006, 18:44:13 by TommyD » Logged
Paczesiowa
Full Member
***
Offline Offline

TF Base: Linux 2.x
Posts: 177



View Profile
« Reply #5 on: 06-30-2006, 18:50:18 »

/sbin/iptables -I STATE -m state --state ESTABLISHED,RELATED -j ACCEPT

there isn't STATE chain by default, I think u meant INPUT...

in "bt client" line u can omit "-d <ip of my bt client> " because every packet in that chain has this destination so why bother checking it? (unless u have multi-IP or multi-NIC or smth more complicated)


and besides this doesnt have to work because tracker isn't forced to give u ip and port of ur friend...
Logged

TommyD
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 49




View Profile
« Reply #6 on: 06-30-2006, 18:55:46 »

/sbin/iptables -I STATE -m state --state ESTABLISHED,RELATED -j ACCEPT

there isn't STATE chain by default, I think u meant INPUT...

in "bt client" line u can omit "-d <ip of my bt client> " because every packet in that chain has this destination so why bother checking it? (unless u have multi-IP or multi-NIC or smth more complicated)


and besides this doesnt have to work because tracker isn't forced to give u ip and port of ur friend...

So that first thing must be : /sbin/iptables -I INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
Huh???

And that '-d <ip>' is because i have 2 ips on one eth0 ... When ip1 is hanging because of a fault in the firewall i can use the second ...

So What i want, i think quiet easy, is something like :

1. Drop all incoming connections.
2. Allow <this> or <that> ipaddress.

And my only question now is ... Is it working like above or isnt it working ? I really need a solution for this problem ... A working one please  Grin
Logged
TommyD
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 49




View Profile
« Reply #7 on: 07-01-2006, 06:45:04 »

Quote
and besides this doesnt have to work because tracker isn't forced to give u ip and port of ur friend...

So how can i block other clients then Huh?

I really dont know how to solve this .. When a client from outside is not giving me his or her ipaddress i dont know how i can block a client ... I red about this module (http://sourceforge.net/projects/iptables-p2p) but there are no examples of what i want ...

Is there someone who knows a solution for this problem Huh??
« Last Edit: 07-01-2006, 07:11:53 by TommyD » Logged
xous
Newbie
*
Offline Offline

TF Base: Linux 2.x
Posts: 1



View Profile
« Reply #8 on: 08-06-2006, 21:23:29 »

After reading through the entire thread I still am unsure of what you are trying to do.

Are you trying to block people from accessing TorrentFlux or block other BitTorrent clients from connecting to TorrentFlux? Both?

Are you trying to force everyone in your network to use TorrentFlux rather than their own torrent client?


Quote
And that '-d <ip>' is because i have 2 ips on one eth0 ... When ip1 is hanging because of a fault in the firewall i can use the second ...

IP's do not "hang"

Quote

I really dont know how to solve this .. When a client from outside is not giving me his or her ipaddress i dont know how i can block a client ...

In order for data to be exchanged over the internet each endpoint MUST know the other's IP Address (Excluding spoofing).
Logged
Pages: [1] Go Up Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by SMF 1.1.1 | SMF © 2006, Simple Machines LLC Powered by PHP