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


  Search this Thread
Old 09-30-2003, 06:24 AM   #1
LQ Newbie
Registered: Sep 2003
Posts: 11

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


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.


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

Rep: Reputation: 66
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, 03:35 PM   #3
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.

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

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




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

All times are GMT -5. The time now is 07:26 PM.

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