Linux Netfilter discussions
 help / color / mirror / Atom feed
From: "Rob Sterenborg" <rob@sterenborg.info>
To: netfilter@vger.kernel.org
Subject: RE: Blocking ports for outsider
Date: Mon, 11 Feb 2008 14:52:50 +0100	[thread overview]
Message-ID: <004f01c86cb5$64a933f0$0b0ffe0a@NS006819> (raw)
In-Reply-To: <1202726951.23042.0.camel@tarak.lk.com>

> Hi,
>     I have a mail server which has two interface eth0[internal],
> eth1[external]. i want certain ports like 25, 110, 995 will
> be open for
> outsider as wel as local, and some port 10000, 5666 , will be open for
> local only.. , if anyone help me out regarding this...
>
> i'm a mail-system guy,so i'm not very much aware of iptables rules, if
> anyone give me some documentation links for Mailling System related
> iptables documentation, that will be helpful for me

It's best practice to have everything closed and just open up the ports
(to specific IP's) where needed.

$LAN could be the network address you're using or a specific IP.

$ipt -P INPUT DROP
$ipt -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
$ipt -A INPUT -m state --state NEW -i lo -j ACCEPT
$ipt -A INPUT -m state --state NEW -p tcp -m multiport \
  --dports 25,110,995 -j ACCEPT
$ipt -A INPUT -m state --state NEW -s $LAN -p tcp \
  -m multiport --dports 5666,10000 -j ACCEPT

If you don't have the multiport match, you can do this instead:

$ipt -P INPUT DROP
$ipt -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
$ipt -A INPUT -m state --state NEW -i lo -j ACCEPT
$ipt -A INPUT -m state --state NEW -p tcp --dport 25 -j ACCEPT
$ipt -A INPUT -m state --state NEW -p tcp --dport 110 -j ACCEPT
$ipt -A INPUT -m state --state NEW -p tcp --dport 995 -j ACCEPT
$ipt -A INPUT -m state --state NEW -s $LAN -p tcp \
  --dport 5666 -j ACCEPT
$ipt -A INPUT -m state --state NEW -s $LAN -p tcp \
  --dport 10000 -j ACCEPT

As you can see the latter do the same rules as the first rules, there
are just more rules to process.

Oskar Andreasson wrote a good iptables tutorial.
http://iptables-tutorial.frozentux.net/iptables-tutorial.html


Grts,
Rob



  reply	other threads:[~2008-02-11 13:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-11 10:49 Blocking ports for outsider Tarak Ranjan
2008-02-11 13:52 ` Rob Sterenborg [this message]
2008-02-13  6:43   ` Tarak Ranjan
2008-02-13 11:53     ` Rob Sterenborg
  -- strict thread matches above, loose matches on Subject: below --
2008-02-11 10:22 Tarak Ranjan

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='004f01c86cb5$64a933f0$0b0ffe0a@NS006819' \
    --to=rob@sterenborg.info \
    --cc=netfilter@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox