From: Antony Stone <Antony@Soft-Solutions.co.uk>
To: netfilter@lists.netfilter.org
Subject: Re: Is this config OK, plus where should I be logging...
Date: Sun, 4 Apr 2004 20:07:23 +0100 [thread overview]
Message-ID: <200404042007.23099.Antony@Soft-Solutions.co.uk> (raw)
In-Reply-To: <000501c41a74$7b0c51f0$0464a8c0@stu>
On Sunday 04 April 2004 7:41 pm, Stuart Lamble wrote:
> Hi
>
> Ok, here is an update...
> I have added the results of iptables-save as is, without hacking
> anything off. ;-)
> I have the firewall box that is running the following...
> mail server on port 25
> ssh server on port 22
> webmin running port 10000 over SSL 443
> web server on port 80
So, this thing is not a firewall, it's a general purpose server which happens
to run some netfilter rules :)
(Yes, I disapprove of firewalls running network services... :)
By the way, what do you mean by "webmin running port 10000 over SSL 443"?
Is this thing listening on port 10000, or port 443? Set up one rule to allow
whichever type of packets you need, and remove the other rule.
> DNAT to another lan server running oracle web services on port 7783 =
> 7783 (from the web)
> DNAT to another lan server running ssh services on port 22 = 555 (from
> the web)
>
> My internal 192.168.100.0/255.255.255.0 is masqueraded for internet
> browsing and prity much everything else.
> The firewall itself needs to do DNS lookups, browse the net and send
> SMTP traffic.
>
> All that I require, stated above is working.
Okay, good.
> I want to know if the config is secure, where are the holes, what are
> the best practices.
Best practice item 1: don't run network services on your firewall :)
As I said in my earlier reply, I can't see why you have bothered to put OUTPUT
ACCEPT rules in place, when you then put a default ACCEPT policy on the
OUTPUT chain (and you have no DROP rules). Absolutely everything is allowed
out of this box, so why not make it obvious that that is the case, instead of
making someone (perhaps you, in six months' time) think that the ACCEPT rules
are there for a purpose and anything not specified will not be allowed?
Also, whilst we're talking about those rules, why have you used multiport, and
then specified only a single port in each rule?
The simpler your rules are, the easier they are to understand.
The more compilcated you make them, the easier it is to make mistakes.
> Also, I want to log suspicious behaviour, port scans, what gets dropped
> etc.
> I am stuck with that ;-(
Put your LOGging rules at the end of FORWARD and INPUT, just before the
default DROP policy takes effect. At first you may as well just log
everything with a simple rule "iptables -A INPUT -j LOG", and then once you
get bored of seeing loads of packets addressed to port 135 on your firewall,
you can DROP those before the LOG rule and start to narrow down what you log
to only the stuff you find interesting.
> # Generated by iptables-save v1.2.7a on Sun Apr 4 22:25:58 2004
> *filter
>
> :INPUT DROP [0:0]
> :FORWARD DROP [0:0]
> :OUTPUT DROP [0:0]
>
> -A INPUT -i lo -j ACCEPT
> -A INPUT -i eth1 -j ACCEPT
> -A INPUT -p icmp -j ACCEPT
> -A INPUT -p tcp -m tcp --sport 25 -j ACCEPT
> -A INPUT -i ppp0 -p tcp -m tcp --dport 22 -j ACCEPT
> -A INPUT -i ppp0 -p tcp -m tcp --dport 25 -j ACCEPT
> -A INPUT -i ppp0 -p tcp -m tcp --dport 80 -j ACCEPT
> -A INPUT -i ppp0 -p tcp -m tcp --dport 443 -j ACCEPT
> -A INPUT -i ppp0 -p tcp -m tcp --dport 10000 -j ACCEPT
> -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
> -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
> -A FORWARD -s 192.168.100.0/255.255.255.0 -j ACCEPT
I still disapprove of the above rule. It will allow packets from the
Internet which have a source address matching your internal network to get
through the firewall. You should tighten it by adding the source interface
eth1 as well:
iptables -A FORWARD -s 192.168.100.0/24 -i eth1 -j ACCEPT
> -A FORWARD -d 192.168.100.6 -p tcp -m tcp --dport 22 -j ACCEPT
> -A FORWARD -d 192.168.100.6 -p tcp -m tcp --dport 7783 -j ACCEPT
> -A OUTPUT -s 127.0.0.1 -j ACCEPT
> -A OUTPUT -o eth1 -j ACCEPT
> -A OUTPUT -p tcp -m tcp --sport 80 -j ACCEPT
You still have INPUT rules for ports 80 and 443, but a OUTPUT rule only for
port 80 (as well as a default ACCEPT policy which will allow the 443 packets
as well as any others). This inconsistency doesn't look good.
> -A OUTPUT -p tcp -m tcp --sport 25 -j ACCEPT
> -A OUTPUT -p tcp -m tcp --sport 22 -j ACCEPT
> -A OUTPUT -o ppp0 -p udp -m udp -m multiport --ports domain -j ACCEPT
> -A OUTPUT -o ppp0 -p tcp -m tcp -m multiport --ports http -j ACCEPT
> -A OUTPUT -o ppp0 -p tcp -m tcp -m multiport --ports smtp -j ACCEPT
> -A OUTPUT -o ppp0 -p tcp -m tcp -m multiport --ports ndmp -j ACCEPT
> COMMIT
> # Completed on Sun Apr 4 22:25:58 2004
Personally I would prefer to see:
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT ......... -j ACCEPT
.... for each type of traffic you want to allow in to the "firewall"
iptables -A OUTPUT ........ -j ACCEPT
.... for each type of traffic you want to allow out
iptables -A FORWARD ........ -j ACCEPT
.... for each type of traffic you want to allow through.
By using the ESTABLISHED,RELATED rules more effectively, you can focus only on
the destination ports in all three chains, and not need to have matching
rules in INPUT and OUTPUT, with source ports in one and destination ports in
the other, as you have done.
Hope this helps,
Regards,
Antony.
--
One good tern deserves another.
Please reply to the list;
please don't CC me.
next prev parent reply other threads:[~2004-04-04 19:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-04 17:26 Is this config OK, plus were should I be logging Stuart Lamble
2004-04-04 17:56 ` Is this config OK, plus where " Antony Stone
2004-04-04 18:41 ` Stuart Lamble
2004-04-04 19:07 ` Antony Stone [this message]
2004-04-05 5:46 ` Stuart Lamble
2004-04-05 9:11 ` Antony Stone
2004-04-05 13:14 ` Unknown, Alistair Tonner
[not found] ` <200404050914.19563.Alistair Tonner <>
2004-04-05 13:34 ` Antony Stone
2004-04-05 13:48 ` Antony Stone
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=200404042007.23099.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