All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joel Newkirk <netfilter@newkirk.us>
To: jacob_chan <jacob_chan@so-net.net.tw>
Cc: tashamaillist@yahoo.com, netfilter@lists.netfilter.org
Subject: Re: How to block all ports except port 21,22,80,8080 ???
Date: Tue, 18 Feb 2003 04:02:58 -0500	[thread overview]
Message-ID: <200302180402.58575.netfilter@newkirk.us> (raw)
In-Reply-To: <1045555939.94722.jacob_chan@so-net.net.tw>

On Tuesday 18 February 2003 03:12 am, jacob_chan wrote:
> How to block all ports except port 21,22,80,8080 ???
>
> Dear all,
>
> I want to block all ports except port 21,22,80,8080.
>
> Any help appreciated.
>
> Best regards,
>
> Jacob

If you mean on input, try:

iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
iptables -A INPUT -p tcp -m multiport --dport 21,22,80,8080 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

These will allow nothing in, nothing out, nothing forwarded, except the 
four specified TCP ports, replies, and associated traffic.  You'd also 
need "insmod ip_conntrack_ftp" for both passive and active FTP to work, 
so that all data communications would be RELATED to the control port 21. 
(and "insmod ip_conntrack" if you don't have it already, for the state 
match to work)

j



      parent reply	other threads:[~2003-02-18  9:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-18  8:12 How to block all ports except port 21,22,80,8080 ??? jacob_chan
2003-02-18  8:57 ` Ralf Spenneberg
2003-02-18  9:30   ` Ralf Spenneberg
2003-02-18 10:15     ` Patrick Maartense
2003-02-18 12:45       ` Ralf Spenneberg
2003-02-18 13:40       ` How to Block MSN Miguel Amador L.
2003-02-18 15:49         ` Arnt Karlsen
2003-02-18 16:03       ` How to block all ports except port 21,22,80,8080 ??? Alexander W. Janssen
2003-02-18 12:19         ` Re2: " Pablo Allietti
2003-02-18 19:40           ` Alexander W. Janssen
2003-02-18 19:51           ` Re2: " Alexander W. Janssen
2003-02-18  9:02 ` Joel Newkirk [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200302180402.58575.netfilter@newkirk.us \
    --to=netfilter@newkirk.us \
    --cc=jacob_chan@so-net.net.tw \
    --cc=netfilter@lists.netfilter.org \
    --cc=tashamaillist@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.