Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
10-15-2007, 02:32 AM
|
#1
|
|
LQ Newbie
Registered: Oct 2003
Location: Calgary, AB, Canada
Distribution: Ubuntu
Posts: 20
Rep:
|
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
|
|
|
|
10-15-2007, 07:24 AM
|
#2
|
|
Member
Registered: Mar 2007
Location: Spain
Distribution: Ubuntu
Posts: 199
Rep:
|
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.
|
|
|
|
10-15-2007, 11:56 AM
|
#3
|
|
Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870
|
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.
|
|
|
|
10-16-2007, 07:09 AM
|
#4
|
|
Member
Registered: Mar 2007
Location: Spain
Distribution: Ubuntu
Posts: 199
Rep:
|
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.
|
|
|
|
10-16-2007, 08:37 AM
|
#5
|
|
Member
Registered: Mar 2007
Distribution: Debian
Posts: 547
Rep:
|
Quote:
Originally Posted by rodrifra
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.
|
|
|
|
10-16-2007, 09:43 AM
|
#6
|
|
LQ Newbie
Registered: Oct 2003
Location: Calgary, AB, Canada
Distribution: Ubuntu
Posts: 20
Original Poster
Rep:
|
Quote:
Originally Posted by win32sux
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.
|
|
|
|
10-16-2007, 10:58 AM
|
#7
|
|
Member
Registered: Mar 2007
Distribution: Debian
Posts: 547
Rep:
|
there is absolutely no difference between them.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:34 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|