From: "Jörg Harmuth" <harmuth@mnemon.de>
To: netfilter@lists.netfilter.org
Subject: Re: Setting up a local firewall
Date: Mon, 01 Aug 2005 14:51:13 +0200 [thread overview]
Message-ID: <42EE1AC1.8040802@mnemon.de> (raw)
In-Reply-To: <42ED87C7.207@filefront.com>
Bryan Christ schrieb:
> I locked myself out of my server until I rebooted it. My goal was to
> lock down everything and allow only SSH connectivity. Can anyone show
> me where my logic went wrong? Here was the fatal script which I wrote:
>
> /sbin/iptables -F INPUT
> /sbin/iptables -A INPUT -s 0/0 -j DROP
> /sbin/iptables -A INPUT -s 0/0 -m state --state NEW,ESTABLISHED -p tcp
> --dport 22 -j ACCEPT
>
> My guess is that I missed accepting syn packets, but I'm not ready to
> "try" again.
No, you didn't miss that. It is in NEW, but this also means, if the
first packet of a connection has only ACK set it will also be in state
NEW. Your problem is the second rule, which droppes all packets in
INPUT, so no SSH packet will ever make it to your ACCEPT rule. Simply
delete the second line and set a policy of DROP|REJECT for INPUT.
BTW, you can omitt "-s 0/0" - it is default. If I were you, I would do
it this way:
iptables -P INPUT DROP
iptables -A INPUT -p tcp --state ESTABLISHD -j ACCEPT
iptables -A INPUT -p tcp --dport 22 --syn -j ACCEPT
[Other useful rules]
iptables -A INPUT -p tcp -j REJECT --reject-with tcp-reset
Have a nice time,
Joerg
next prev parent reply other threads:[~2005-08-01 12:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-01 2:24 Setting up a local firewall Bryan Christ
2005-08-01 12:20 ` Jan Engelhardt
2005-08-01 12:49 ` Bjørn Ruberg
2005-08-01 12:51 ` Jörg Harmuth [this message]
2005-08-01 12:54 ` /dev/rob0
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=42EE1AC1.8040802@mnemon.de \
--to=harmuth@mnemon.de \
--cc=netfilter@lists.netfilter.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 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.