LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-09-2007, 08:52 AM   #1
Hammett
Senior Member
 
Registered: Aug 2003
Location: Barcelona, Catalunya
Distribution: Gentoo
Posts: 1,074

Rep: Reputation: 59
Iptables question


Hi all!

I've got a question regarding IPTables. I have configured IPTables through Guarddog to enable range port 6882-6889 UDP to get Bittorrent connectios go faster, but in the logs the firewall drops the connections.

This is the iptables rule
Code:
ACCEPT     udp  --  anywhere             anywhere            udp dpts:6882:6889
And here the log file
Code:
DROPPED IN=eth0 OUT= MAC=00:1b:fc:92:bc:84:00:16:b6:ac:f3:34:08:00 SRC=88.115.129.42 DST=192.168.1.101 LEN=95 TOS=0x00 PREC=0x00 TTL=110 ID=48976 PROTO=UDP SPT=61517 DPT=6882 LEN=75
and the loaded modules for IPTables
Code:
nf_conntrack_irc        8864  0 
nf_conntrack_ftp       11296  0 
ipt_REJECT              6208  4 
ipt_LOG                 8128  6 
xt_limit                5120  6 
xt_tcpudp               5632  41 
nf_conntrack_ipv4      17808  38 
xt_state                4608  38 
nf_conntrack           59740  4 nf_conntrack_irc,nf_conntrack_ftp,nf_conntrack_ipv4,xt_state
nfnetlink               7304  2 nf_conntrack_ipv4,nf_conntrack
iptable_filter          4992  1 
ip_tables              18920  1 iptable_filter
x_tables               17160  6 ipt_REJECT,ipt_LOG,xt_limit,xt_tcpudp,xt_state,ip_tables
Am I missing something here??
 
Old 09-09-2007, 09:02 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
that rule is for udp. bitorrent uses tcp, not udp.
 
Old 09-09-2007, 09:06 AM   #3
Hammett
Senior Member
 
Registered: Aug 2003
Location: Barcelona, Catalunya
Distribution: Gentoo
Posts: 1,074

Original Poster
Rep: Reputation: 59
You can use UDP connections as well for decentralized transfer. But the question here is why if I have a rule that enables UDP connections on range port 6882-6889, the firewall drops them
 
Old 09-09-2007, 09:08 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
oh, sorry yeah the drop is for UDP... my bad, i would assume that it would be a higher up rule in the table then.

yeah seems there are a few odd clients which do allow UDP. learn something new every day.
 
Old 09-09-2007, 09:23 AM   #5
Hammett
Senior Member
 
Registered: Aug 2003
Location: Barcelona, Catalunya
Distribution: Gentoo
Posts: 1,074

Original Poster
Rep: Reputation: 59
In that case, I'll post the whole IPTables setting to see if anyone can point me out where's the conflicting rule

Code:
Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  192.168.1.101        192.168.1.255       
logaborted  tcp  --  anywhere             anywhere            state RELATED,ESTABLISHED tcp flags:RST/RST 
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
ACCEPT     icmp --  anywhere             anywhere            icmp destination-unreachable 
ACCEPT     icmp --  anywhere             anywhere            icmp time-exceeded 
ACCEPT     icmp --  anywhere             anywhere            icmp parameter-problem 
nicfilt    all  --  anywhere             anywhere            
srcfilt    all  --  anywhere             anywhere            

Chain FORWARD (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
ACCEPT     icmp --  anywhere             anywhere            icmp destination-unreachable 
ACCEPT     icmp --  anywhere             anywhere            icmp time-exceeded 
ACCEPT     icmp --  anywhere             anywhere            icmp parameter-problem 
srcfilt    all  --  anywhere             anywhere            

Chain OUTPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
ACCEPT     icmp --  anywhere             anywhere            icmp destination-unreachable 
ACCEPT     icmp --  anywhere             anywhere            icmp time-exceeded 
ACCEPT     icmp --  anywhere             anywhere            icmp parameter-problem 
s1         all  --  anywhere             anywhere            

Chain f0to1 (3 references)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:65535 dpts:6881:6889 state NEW
ACCEPT     icmp --  anywhere             anywhere            icmp echo-reply 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:65535 dpt:4662 state NEW 
ACCEPT     udp  --  anywhere             anywhere            udp spts:1024:65535 dpt:4666 
logdrop    all  --  anywhere             anywhere            

Chain f1to0 (1 references)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:cvsup dpt:svn state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:cvsup dpts:6881:6889 state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:56740 state NEW 
ACCEPT     icmp --  anywhere             anywhere            icmp echo-request 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:https state NEW 
ACCEPT     udp  --  anywhere             anywhere            udp dpt:18951 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:cvsup dpt:cvspserver state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:cvsup dpt:rsync state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:cvsup dpt:ftp state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:cvsup dpt:1863 state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:cvsup dpt:888 state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:cvsup dpts:6660:6669 state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:2234 state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:cvsup dpt:8880 state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:2710 state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:6969 state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:domain state NEW 
ACCEPT     udp  --  anywhere             anywhere            udp dpt:domain 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:53880 state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:cvsup dpt:https state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:2240 state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:3411 state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpts:3390:3391 state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:cvsup dpt:http state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:cvsup dpt:http-alt state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:cvsup dpt:http-alt state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:cvsup dpt:8000 state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:cvsup dpt:8888 state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:cvsup dpt:6969 state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:3552 state NEW 
ACCEPT     udp  --  anywhere             anywhere            udp dpt:6969 
ACCEPT     udp  --  anywhere             anywhere            udp dpts:6882:6889 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:cvsup dpt:4661 state NEW 
ACCEPT     tcp  --  anywhere             anywhere            tcp spts:1024:cvsup dpt:4662 state NEW 
ACCEPT     udp  --  anywhere             anywhere            udp spts:1024:cvsup dpt:4665 
ACCEPT     udp  --  anywhere             anywhere            udp spts:1024:cvsup dpt:4666 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:3411 state NEW 
logreject  tcp  --  anywhere             anywhere            tcp dpts:6881:6999 state NEW 
logdrop    all  --  anywhere             anywhere            

Chain logaborted (1 references)
target     prot opt source               destination         
logaborted2  all  --  anywhere             anywhere            limit: avg 1/sec burst 10 
LOG        all  --  anywhere             anywhere            limit: avg 2/min burst 1 LOG level warning prefix `LIM
ITED ' 

Chain logaborted2 (1 references)
target     prot opt source               destination         
LOG        all  --  anywhere             anywhere            LOG level warning tcp-sequence tcp-options ip-options 
prefix `ABORTED ' 
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 

Chain logdrop (4 references)
target     prot opt source               destination         
logdrop2   all  --  anywhere             anywhere            limit: avg 1/sec burst 10 
LOG        all  --  anywhere             anywhere            limit: avg 2/min burst 1 LOG level warning prefix `LIM
ITED ' 
DROP       all  --  anywhere             anywhere            

Chain logdrop2 (1 references)
target     prot opt source               destination         
LOG        all  --  anywhere             anywhere            LOG level warning tcp-sequence tcp-options ip-options 
prefix `DROPPED ' 
DROP       all  --  anywhere             anywhere            

Chain logreject (1 references)
target     prot opt source               destination         
logreject2  all  --  anywhere             anywhere            limit: avg 1/sec burst 10 
LOG        all  --  anywhere             anywhere            limit: avg 2/min burst 1 LOG level warning prefix `LIM
ITED ' 
REJECT     tcp  --  anywhere             anywhere            reject-with tcp-reset 
REJECT     udp  --  anywhere             anywhere            reject-with icmp-port-unreachable 
DROP       all  --  anywhere             anywhere            

Chain logreject2 (1 references)
target     prot opt source               destination         
LOG        all  --  anywhere             anywhere            LOG level warning tcp-sequence tcp-options ip-options 
prefix `REJECTED ' 
REJECT     tcp  --  anywhere             anywhere            reject-with tcp-reset 
REJECT     udp  --  anywhere             anywhere            reject-with icmp-port-unreachable 
DROP       all  --  anywhere             anywhere            

Chain nicfilt (1 references)
target     prot opt source               destination         
RETURN     all  --  anywhere             anywhere            
RETURN     all  --  anywhere             anywhere            
RETURN     all  --  anywhere             anywhere            
logdrop    all  --  anywhere             anywhere            

Chain s0 (1 references)
target     prot opt source               destination         
f0to1      all  --  anywhere             192.168.1.101       
f0to1      all  --  anywhere             192.168.1.255       
f0to1      all  --  anywhere             localhost           
logdrop    all  --  anywhere             anywhere            

Chain s1 (1 references)
target     prot opt source               destination         
f1to0      all  --  anywhere             anywhere            

Chain srcfilt (2 references)
target     prot opt source               destination         
s0         all  --  anywhere             anywhere
Thanks a lot for having a look at it
 
Old 09-09-2007, 12:38 PM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Well whilst you have the rule in there, the table it's in is only referenced by the OUTPUT table, but it's the INPUT table that would be reciving this packet. i don't know guarddog so don't know how that relates to the UI, but essentially it's looking for outbound data, not inbound data, which it should be.
 
Old 09-09-2007, 01:46 PM   #7
Hammett
Senior Member
 
Registered: Aug 2003
Location: Barcelona, Catalunya
Distribution: Gentoo
Posts: 1,074

Original Poster
Rep: Reputation: 59
The rule is set to be bidirectional. A closer look to the guarddog script shows this:
Code:
iptables -A f1to0 -p udp --sport 0:65535 --dport 6882:6889 -j ACCEPT
As far as I understand, what that rule say is that any traffic from any IP and port directed to UDP range 6882-6889 on my machine has to be allowed. Is that wright? If not, what should the rule be to achieve that?
 
Old 09-09-2007, 02:04 PM   #8
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
the rule in itself is fine, but it appears to be in the wrong place. if you look at the tables above, incoming data startings with the INPUT table, and that hooks into the guarddog tables with the reference to the srcfilt table. that references s0, and s0 references f0to1. f0to1 then ends up referncing logdrop, which is what's doing the logging and dropping you're seeing. at no stage does incoming data get anywhere near that rule.
 
Old 09-09-2007, 06:38 PM   #9
Hammett
Senior Member
 
Registered: Aug 2003
Location: Barcelona, Catalunya
Distribution: Gentoo
Posts: 1,074

Original Poster
Rep: Reputation: 59
OK, I decided to build a firewall myself from what I learned here and some piece of script of Guarddog itself.
I'd like if someone could comment on the firewall. Weaknesses that might have and this kind of things.

Code:
# Generated by Hammett on Mon 10th Sep 2007
*filter
# Shut down all traffic
-P FORWARD DROP
-P INPUT DROP
-P OUTPUT DROP

# Clear all rules
-F
-X

# accept all from localhost
-A INPUT -s 127.0.0.1 -j ACCEPT
-A OUTPUT -o 127.0.0.1 -j ACCEPT

# Allow DNS
-A OUTPUT -p tcp --sport 0:65535 --dport 53:53 -j ACCEPT
-A INPUT -p tcp ! --syn --sport 53:53 --dport 0:65535 -j ACCEPT
-A OUTPUT -p udp --sport 0:65535 --dport 53:53 -j ACCEPT
-A INPUT -p udp --sport 53:53 --dport 0:65535 -j ACCEPT

# accept all previously established connections
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

# Allow HTTP,HTTPS
-A OUTPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A OUTPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT

# Allow ftp
-A OUTPUT -p tcp -m state --state NEW -m tcp --dport 20:21 -j ACCEPT

# Allow ping
-A OUTPUT -p icmp --icmp-type echo-request -j ACCEPT
-A INPUT -p icmp --icmp-type echo-reply -j ACCEPT

# Allow Bit-torrent connections
-A INPUT -p tcp -m state --state NEW -m tcp --dport 6881:6889 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp --dport 6881:6999 -j ACCEPT
-A OUTPUT -p tcp -m state --state NEW -m tcp --dport 6881:6889 -j ACCEPT
-A OUTPUT -p udp -m state --state NEW -m udp --dport 6881:6999 -j ACCEPT

# Allow MSN Messenger
-A INPUT -p tcp -m state --state NEW -m tcp --dport 1863 -j ACCEPT
-A OUTPUT -p tcp -m state --state NEW -m tcp --dport 1863 -j ACCEPT

# Allow eDonkey
-A INPUT -p tcp -m state --state NEW -m tcp --dport 4661:4662 -j ACCEPT
-A INPUT -p udp -m state --state NEW -m udp --dport 4665:4666 -j ACCEPT
-A OUTPUT -p tcp -m state --state NEW -m tcp --dport 4661:4662 -j ACCEPT
-A OUTPUT -p udp -m state --state NEW -m udp --dport 4665:4666 -j ACCEPT

# Allow IRC
-A OUTPUT -p tcp -m state --state NEW -m tcp --dport 6665:6669 -j ACCEPT

# LOG everything that does not fit on the rules above
-N logdrop
-A logdrop -j LOG --log-prefix "DROPPED " --log-level 4 --log-ip-options --log-tcp-options --log-tcp-sequence 
-A logdrop -j DROP

COMMIT
It seems the system is not logging the dropped packets. I copied the script from Guarddog, but seems not to work on this one

Thanks a lot for having a look at the script
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
iptables question vijeesh Linux - Newbie 2 08-06-2006 03:20 AM
iptables v1.2.9: Unknown arg `/sbin/iptables' Try `iptables -h' or 'iptables --help' Niceman2005 Linux - Security 4 12-29-2005 08:20 PM
iptables question Ipolit Slackware 2 06-01-2005 03:27 PM
iptables question iomari Linux - Security 4 01-13-2005 12:14 AM
Iptables Question Neomaster Linux - Security 4 06-18-2003 08:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration