From: Antony Stone <Antony@Soft-Solutions.co.uk>
To: netfilter@lists.netfilter.org
Subject: Re: block port 137
Date: Wed, 4 Aug 2004 08:03:02 +0100 [thread overview]
Message-ID: <200408040803.02568.Antony@Soft-Solutions.co.uk> (raw)
In-Reply-To: <00d601c479cf$352a91f0$858310ac@suarapembaruan.com>
On Wednesday 04 August 2004 4:00 am, david wrote:
> Dear Antony,
> I agree with you, i must block all traffic and accept one-by-one rules that
> i want, but the problem is i don't know how to do this
1. Here's the basic idea:
iptables -P FORWARD DROP
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i $INTIF -p tcp --dport 80 -j ACCEPT
iptables -A FORWARD -i $INTIF -p udp --dport 53 -j ACCEPT
iptables -A FORWARD -i $INTIF -p tcp --dport 53 -j ACCEPT
iptables -A FORWARD -j LOG
These rules mean "DROP any packets which I don't have a rule to ACCEPT, then
ACCEPT all packets except the first of any connection, then ACCEPT the first
packets for web browsing and DNS, then LOG any other packets which try to get
through."
2. The important part of the above ruleset, for someone like you who is not
quite sure what rules to use to ACCEPT the packets you want (and you don't
want to default DROP any packets by omission), is the final LOG rule.
That rule will tell you what packets are trying to get through the ruleset,
but haven't been ACCEPTed by one of the previous rules - and you may want to
add a rule to specifically ACCEPT some of them. Of course, you may *not*
want to accept some of them either, so you're happy for those to continue
being DROPped. In that case (packets you know that you don't want), the
next refinement of the ruleset is:
3. Add some specific DROP rules just before the final LOG rule, so that the
packets you know about and do not want get DROPped without being logged.
The final outcome of this is a ruleset which:
a) ACCEPTs the packets you know you want
b) DROPs the packets you know you don't want
c) LOGs any other packets you haven't thought about or weren't expecting
As you can see, you can build such a ruleset gradually - if you don't want to
disrupt communications through the firewall as you do it, just leave the
default policy on ACCEPT as you add the specific ACCEPT rules, and then once
you have no more wanted packets being DROPped, you can set the policy to DROP
and concentrate on cutting down what gets LOGged.
I do recommend studying one of the netfilter tutorials such as Oskar
Andreasson's at http://iptables-tutorial.frozentux.net so that you get a
better understanding of how packets make their way through netfilter, and
also what packets are necessary for correct and efficient operation of a
network (some of them may be non-obvious, such as TCP DNS in my mini-ruleset
above, or certain types of ICMP packets etc).
Regards,
Antony.
--
Anyone that's normal doesn't really achieve much.
- Mark Blair, Australian rocket engineer
Please reply to the list;
please don't CC me.
next prev parent reply other threads:[~2004-08-04 7:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-30 0:20 SMB auth and Iptables Steve Wakelin
[not found] ` <"002401c 4 7917$d0a6fd70$858310ac"@suarapembaruan.com>
2004-08-03 5:07 ` block port 137 david
2004-08-03 6:04 ` Dhananjoy Chowdhury
2004-08-03 6:17 ` Antony Stone
2004-08-03 7:33 ` Dhananjoy Chowdhury
2004-08-03 8:41 ` Antony Stone
2004-08-03 9:16 ` Frank Gruellich
2004-08-04 3:00 ` david
2004-08-04 7:03 ` Antony Stone [this message]
2004-08-04 10:01 ` david
2004-08-04 7:41 ` Frank Gruellich
2004-08-03 6:15 ` Antony Stone
2004-08-03 18:31 ` Zoup
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=200408040803.02568.Antony@Soft-Solutions.co.uk \
--to=antony@soft-solutions.co.uk \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox