Skip to contentSkip to conversation

block ports

DISCUSSION Stewart Thompson 1 participant 1 message Sep 16, 2002 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Hi Payal:

The rule below would allow all connections except
On port 22 because of the !.. Set your policy to Drop and then have a rule allowing each port you want to let in.

#iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT

Stu........

-----Original Message-----
From: [email protected] [mailto:[email protected]]On Behalf Of PayalR
Sent: September 16, 2002 12:03 AM
To: [email protected]
Subject: block ports

Hi all,
I have a stupid question. I want to have incoming internet access for only port 22, 25, 80 and 110. How do I go abut it?
I thought of this rule first,

#iptables -A INPUT -i eth0 -p tcp --dport ! 22 -j DROP

and go for the other ports as well. But my problem is that if a packet arrives from port 110, it will be checked for rule 1 above and since it is not for port 22 it will be dropped disregarding the next rules. Right?

What can I do about this? How do I exactly frame the rules? Thanks a lot and bye.
-Payal