LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices

Reply
 
Search this Thread
Old 10-15-2007, 02:32 AM   #1
Calab
Member
 
Registered: Oct 2003
Location: Calgary, AB, Canada
Distribution: CentOS, Ubuntu
Posts: 32

Rep: Reputation: 0
iptables dropping responses from web, dns, ftp servers I try to connect to?


I'm trying to secure my Debian etch 4.0r1 machine. I've built some rules for iptables, but I think that they are blocking responses from the servers I am connecting to. For example, if I do a lookup on google.ca the request is sent by my PC, but the reply comes in on a port that IPTABLES isn't allowing. How do I let these responses through?

I can connect to SSH on this PC from another PC on my LAN, so I know that the interfaces are working.

My IPTABLES rules, according to WebMin:

# INPUT

Accept If protocol is ICMP and ICMP type is echo-request
Accept If protocol is TCP and input interface is eth2 and destination port is 22
Accept If protocol is UDP and input interface is eth2 and destination port is 22
Accept If protocol is TCP and input interface is eth2 and destination port is 20:21
Accept If protocol is TCP and input interface is eth2 and source port is 14400:14499
Drop If input interface is eth2

#eth1 is behind a router, so SMB shares are NOT public.
Accept If protocol is TCP and input interface is eth1 and destination port is 22
Accept If protocol is UDP and input interface is eth1 and destination port is 22
Accept If protocol is TCP and source is 10.0.11.0/24 and input interface is eth1 and destination port is 139
Accept If protocol is UDP and source is 10.0.11.0/24 and input interface is eth1 and destination port is 139
Accept If protocol is TCP and source is 10.0.11.0/24 and input interface is eth1 and destination port is 445
Accept If protocol is UDP and source is 10.0.11.0/24 and input interface is eth1 and destination port is 445
Accept If protocol is TCP and input interface is eth1 and destination port is 55555
Drop If input interface is eth1

Accept If protocol is UDP and input interface is eth0 and destination port is 18800:18899
Accept If protocol is TCP and input interface is eth0 and destination port is 18800:18899
Accept If protocol is TCP and input interface is eth0 and destination port is 6881:6999
Accept If protocol is TCP and input interface is eth0 and destination port is 22
Accept If protocol is UDP and input interface is eth0 and destination port is 22
Drop If input interface is eth0

# OUTPUT
Default = Accept

# FORWARDED
Default = Accept
 
Old 10-15-2007, 07:24 AM   #2
rodrifra
Member
 
Registered: Mar 2007
Location: Spain
Distribution: Ubuntu
Posts: 199

Rep: Reputation: 36
Hi.
I don't know much about security or iptables, so this may not be the best solution, but it works fine for me.

iptables -I INPUT -m conntrack --cstate ESTABLISHED -j ACCEPT

This will let all incoming connections if we have stablished that connection. Which means (I hope :P) that only those connections that we have started are allowed.
 
Old 10-15-2007, 11:56 AM   #3
win32sux
Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
I'm not familiar with the cstate match (in fact, the command you posted won't work at all on my Ubuntu box), so I'll post the more traditional way to do this:
Code:
iptables -I INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

Last edited by win32sux; 10-15-2007 at 03:25 PM.
 
Old 10-16-2007, 07:09 AM   #4
rodrifra
Member
 
Registered: Mar 2007
Location: Spain
Distribution: Ubuntu
Posts: 199

Rep: Reputation: 36
Ups. It is always better to copy and paste than using memmory :P.
It is ctstate. I'm sorry for the mistake. The command would be (with copy and paste)

iptables -I INPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT

It should work now, I'm using kubuntu feisty.
regards.
 
Old 10-16-2007, 08:37 AM   #5
almatic
Member
 
Registered: Mar 2007
Distribution: Debian
Posts: 547

Rep: Reputation: 67
Quote:
Originally Posted by rodrifra View Post
Ups. It is always better to copy and paste than using memmory :P.
It is ctstate. I'm sorry for the mistake. The command would be (with copy and paste)

iptables -I INPUT -m conntrack --ctstate ESTABLISHED -j ACCEPT

It should work now, I'm using kubuntu feisty.
regards.
'established' is not enough for ftp, since ftp uses 2 connections, which need to be recognized as 'related', so if you want ftp, use the command from win32sucks. It doesn't matter if you use 'ctstate' or 'state' match, the difference is, that ctstate provides some more matches.
 
Old 10-16-2007, 09:43 AM   #6
Calab
Member
 
Registered: Oct 2003
Location: Calgary, AB, Canada
Distribution: CentOS, Ubuntu
Posts: 32

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by win32sux View Post
I'm not familiar with the cstate match (in fact, the command you posted won't work at all on my Ubuntu box), so I'll post the more traditional way to do this:
Code:
iptables -I INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
This is working... What is the difference between this and iptables -I INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT ?

Last edited by Calab; 10-16-2007 at 09:44 AM.
 
Old 10-16-2007, 10:58 AM   #7
almatic
Member
 
Registered: Mar 2007
Distribution: Debian
Posts: 547

Rep: Reputation: 67
there is absolutely no difference between them.
 
  


Reply

Tags
iptables


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
setup needed to run web servers using free dns services nirmaltom Linux - Networking 22 01-18-2007 09:57 AM
can't connect via ftp on my lan....this is my iptables config.... loboautoma Linux - Security 8 01-28-2005 01:14 AM
SuSEPersonal 9.1 How to connect to BT openworldGot the DNS servers IP'sandISP number DemoniX Linux - Newbie 2 08-10-2004 12:39 PM
DNS, Web, FTP, SMTP Rajesh Nakrani Linux - Networking 5 10-09-2003 01:48 AM
FTP and Web Servers xtremcoder Linux - Networking 2 06-16-2003 08:14 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration