LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   IPTABLES Three way Hand shack ? (https://www.linuxquestions.org/questions/linux-networking-3/iptables-three-way-hand-shack-846635/)

gardenair 11-26-2010 12:58 AM

IPTABLES Three way Hand shack ?
 
Hi,
I need a rule for my IPTABLE for three way hand shack method. Example in a datail.

Code:

1-Host A sends a TCP SYNchronize packet to Host B

2-Host B receives A's SYN

3-Host B sends a SYNchronize-ACKnowledgement

4-Host A receives B's SYN-ACK

5-Host A sends ACKnowledge

6-Host B receives ACK.
  TCP socket connection is ESTABLISHED

well by this step a normal user can understand how two computers communicate each others.Please can u help me that how can I write a rule using iptables for three way Hand shack.

thanks
mypass

kaushalpatel1982 11-26-2010 01:31 AM

iptables -A INPUT -s A -d B --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -s B -d A --state NEW,ESTABLISHED,RELATED -j ACCEPT

gardenair 11-26-2010 02:53 AM

Thanks "kaushalpatel" for the reply. Well can we break the IP table in more comprehensive way like as following



Code:

PC A to PB B
1- # iptables -A INPUT -sA -dB -m state --state NEW -j ACCEPT i.e PC A  connect to PC B.

2- # iptables -A INPUT -sB -dA -m state --state RELETED -j APPEPT i.ePC B send Sync and Acknow to PC A.

3- # iptables -A INPUT -sA -dB -m state --state ESTABLISH -J accept i.e connection establish

PC B to PB A

4- # iptables -A INPUT -sB -dA -m state --state NEW -j ACCEPT   

5- # iptables -A INPUT -sA -dB -m state --state RELETED -j APPEPT

6- # iptables -A INPUT -sB -dA -m state --state ESTABLISH -J accept

is it correct  ?


kaushalpatel1982 11-26-2010 01:16 PM

FYI, Number of rules will add delay in the packet transitions. It also add headache for management when the scenarios is wide. In linux I follow the rule "KISS".

archtoad6 11-28-2010 10:01 AM

OP, I do hope you clean up the spelling in your commands in post #3 before you use try to use them.

win32sux 11-28-2010 11:28 AM

gardenair, you might want to read up on the RELATED match, because it doesn't do what you seem to think it does. In fact, the RELATED match isn't even necessary for what you have outlined. Example:
Code:

iptables -A FORWARD -m state --state ESTABLISHED -j ACCEPT
iptables -A FORWARD -s $HOST_A -d $HOST_B -m state --state NEW -j ACCEPT



All times are GMT -5. The time now is 12:05 PM.