From: "Rob Sterenborg" <rob@sterenborg.info>
To: netfilter@vger.kernel.org
Subject: RE: Blocking ports for outsider
Date: Wed, 13 Feb 2008 12:53:17 +0100 [thread overview]
Message-ID: <001601c86e37$0636a400$0b0ffe0a@NS006819> (raw)
In-Reply-To: <1202884987.12351.7.camel@tarak.lk.com>
> i have made one iptables rule set for my mailserver, but the thing is
> that what i want from my rules, it's not responding in that way i
> want... might be some thing wrong with my ruleset.
>
>
> 1) Locally incoming ssh should be allowed from 2 local ips
> 2) 25, 110, 995, 80, 443 should be open for 0/0.
> 3) 10000, 5666 should be open for LAN[192.168.1.0/24] Network
>
> Those are the things i want..... Here is my ruleset in my
> MAILSERVER not in Gateway
> # smtp One per second limt -burst rate of FIVE
> $IPTABLES -A INPUT -p tcp --dport 25 --syn -m limit --limit 1/s
> --limit-burst 5 -j ACCEPT
> $IPTABLES -A INPUT -p tcp --dport 25 --syn -j DROP
> $IPTABLES -A INPUT -p tcp --dport 25 -j ACCEPT
I don't think this will ever match. You accept 1 conn/sec on dport
25/tcp. Connections at a higher rate than 1/sec are DROPped. So what's
left to accept?
> $IPTABLES -A INPUT -m state --state NEW -p tcp -m multiport --dports
> 110,995,443,80,53 -j ACCEPT
Are you running a DNS server for the internet that only allows tcp
connections?
> #OUTPUT RULES
> $IPTABLES -A OUTPUT -o lo -j ACCEPT
I hadn't read all of the above yet, but this can be a (the) problem. You
only allow outgoing packets that use the lo interface. So, you may get
incoming packets from another host, but nothing will ever get out via
the actual network interfaces.
> #FORWARD RULES
> $IPTABLES -A FORWARD -m state --state INVALID -j DROP
Try with a simple ruleset first. If it works, you add more rules or
change them to be even more restrictive (but still let things work as
they should).
$ipt -P INPUT DROP
$ipt -P OUTPUT DROP
$ipt -P FORWARD DROP
$ipt -F
$ipt -X
$ipt -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
$ipt -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
$ipt -N NEW_IN
# ssh in for LAN_IP1
$ipt -A NEW_IN -s $LAN_IP1 -p tcp --dport 22 -j ACCEPT
# ssh in for LAN_IP2
$ipt -A NEW_IN -s $LAN_IP2 -p tcp --dport 22 -j ACCEPT
# smtp in
$ipt -A NEW_IN -p tcp --dport 25 -j ACCEPT
# http in
$ipt -A NEW_IN -p tcp --dport 80 -j ACCEPT
# pop3 in
$ipt -A NEW_IN -p tcp --dport 110 -j ACCEPT
# https in
$ipt -A NEW_IN -p tcp --dport 443 -j ACCEPT
# pop3s in
$ipt -A NEW_IN -p tcp --dport 995 -j ACCEPT
# unknown service1 in for the LAN
$ipt -A NEW_IN -s $LAN_NET -p tcp --dport 5666 -j ACCEPT
# unknown service2 in for the LAN
$ipt -A NEW_IN -s $LAN_NET -p tcp --dport 10000 -j ACCEPT
$ipt -A INPUT -i lo -j ACCEPT
$ipt -A INPUT -m state --state NEW -j NEW_IN
$ipt -N NEW_OUT
# smtp out
$ipt -A NEW_OUT -p tcp --dport 25 -j ACCEPT
# dns out (tcp)
$ipt -A NEW_OUT -p tcp --dport 53 -j ACCEPT
# dns out (udp)
$ipt -A NEW_OUT -p udp --dport 53 -j ACCEPT
# icmp out
$ipt -A NEW_OUT -p icmp -j ACCEPT
$ipt -A OUTPUT -o lo -j ACCEPT
$ipt -A OUTPUT -m state --state NEW -j NEW_OUT
I think this should get you going. If it doesn't, place some logging
rules where appropriate to see where things are allowed or denied.
Grts,
Rob
next prev parent reply other threads:[~2008-02-13 11:53 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
2008-02-13 6:43 ` Tarak Ranjan
2008-02-13 11:53 ` Rob Sterenborg [this message]
-- 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='001601c86e37$0636a400$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