LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-30-2003, 07:24 AM   #1
gpagedar
LQ Newbie
 
Registered: Sep 2003
Posts: 11

Rep: Reputation: 0
Question what is ESTABLISHED, RELATED or NEW


Hi,

i have a machine acting as a gateway and connected to internal and external network. Firstly i need to allow only http and smtp services to the external netwrok, bcoz i have appache running on one of internal network . How do i do that????


secondly what does ESTABLISHED RELATED and NEW mean. i have been reading about this on the web and could hardly understand the need. can someone make me clear about this with example if possible.


Regards,

Gautam
Center for information and Netwrok Security
 
Old 09-30-2003, 02:48 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 64
To block off all unwanted connections:
# Allow http
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
# Allow smtp
iptables -A INPUT -p tcp --dport 25 -j ACCEPT
# Drop everything else
iptables -P INPUT DROP

ESTABLISHED RELATED and NEW are connection states - you can use them to say that only certain types of connction are allowed to pass through a rules table.
 
Old 09-30-2003, 04:35 PM   #3
Miky
Member
 
Registered: Dec 2002
Location: London / Paris
Distribution: Debian / OpenBsd
Posts: 74

Rep: Reputation: 15
It's particularly usefull in the ftp passive mode, it actually know the state of a connexion.

control channel
on port 21 you write your two rules, with new and established
data channel
on >1024 port you write your two rules with related and established
Related means that another connexion has been previously opened.

You'll find many exemples about this on the internet.

Another exemple is
# Allow you to connect to http servers
iptables -A INPUT -p tcp --sport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT
Imagine you just open this on your machine, some may think they are protected from scans because they block all incomming ports except the ones from remote port 80 because you need to accept dialog with the http server.
But imagine the evil guy specifies his source port as 80 to scan your machine, then it's like you didn't have any firewall.

Solution :
iptables -A INPUT -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT #This is the first rule used when the connection is opened

So now if someone scans from port 80, packets will be droped because no connexion would have been previously opened to match this rule
iptables -A INPUT -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT

If it doesn't make sense it might be my english and/or read more documentation about this.

Cheers
 
Old 10-01-2003, 01:29 AM   #4
gpagedar
LQ Newbie
 
Registered: Sep 2003
Posts: 11

Original Poster
Rep: Reputation: 0
Thanxs david and miky for your kind help....

:-)

Regards,
Gautam
 
  


Reply


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
Disconnect An Established Connection metallica1973 Linux - Security 11 08-31-2005 10:15 PM
How to use ESTABLISHED,RELATED best? Pastorino Linux - Security 2 08-30-2005 06:21 PM
How to reset established connection? G-Fox Linux - Networking 4 10-02-2003 03:53 PM
iptables: block ports and RELATED, ESTABLISHED Klaus Pforte Linux - Security 6 07-17-2003 11:00 AM
problems with established connection nbc Linux - Newbie 1 08-16-2001 02:11 AM


All times are GMT -5. The time now is 03:46 PM.

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