From: "Michael J. Tubby B.Sc. \(Hons\) G8TIC" <mike.tubby@thorcom.co.uk>
To: Mark Ryan <markryan@cfl.rr.com>
Cc: netfilter@lists.netfilter.org
Subject: Re: Dynamic Deny rule
Date: Sat, 4 Jan 2003 18:29:21 -0000 [thread overview]
Message-ID: <001d01c2b41f$334d8760$0a90a8c0@boris> (raw)
In-Reply-To: 000101c2b405$a39f7dd0$0501a8c0@underworld
Mark,
Why don't you make a user table called something like
"ftp_check" then add to the chain the IPs of people that you
want to ban from connecting, finishing up with a rules that
accepts everyone else...
You probably have a fairly common setup where incoming
packets on your public interface were first inspected for
protocol and vectored on to one of a number of user tables:
$IPTABLES -A INPUT -p ICMP -i $INET_IFACE -j inet_icmp
$IPTABLES -A INPUT -p TCP -i $INET_IFACE -j inet_tcp
$IPTABLES -A INPUT -p UDP -i $INET_IFACE -j inet_udp
You probably (should) have a "tcp_allowed" chain for state matching,
something like this:
$IPTABLES -A tcp_allowed -p TCP --syn -j ACCEPT
$IPTABLES -A tcp_allowed -p TCP -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A tcp_allowed -p TCP -j DROP
which is where you send TCP sessions that you want to accept
(match address and port number), and hence your "inet_tcp" table
would look something like this:
$IPTABLES -A inet_tcp -p TCP -s 0/0 --dport 21 -j tcp_allowed # FTP control
$IPTABLES -A inet_tcp -p TCP -s 0/0 --dport 25 -j tcp_allowed # SMTP
$IPTABLES -A inet_tcp -p TCP -s 0/0 --dport 80 -j tcp_allowed # Web
$IPTABLES -A inet_tcp -p TCP -s 0/0 --dport 22 -j tcp_allowed # SSH
would change to use the new table for FTP control connections, so that
$IPTABLES -A inet_tcp -p TCP -s 0/0 --dport 21 -j ftp_check # FTP control
$IPTABLES -A inet_tcp -p TCP -s 0/0 --dport 25 -j tcp_allowed # SMTP
$IPTABLES -A inet_tcp -p TCP -s 0/0 --dport 80 -j tcp_allowed # Web
$IPTABLES -A inet_tcp -p TCP -s 0/0 --dport 22 -j tcp_allowed # SSH
and your new "ftp_check" table would have something like:
$IPTABLES -A ftp_check -p TCP -s <banned #1> -j REJECT
$IPTABLES -A ftp_check -p TCP -s <banned #2> -j REJECT
$IPTABLES -A ftp_check -p TCP -s <banned #2> -j REJECT
$IPTABLES -A ftp_check -p TCP -s 0/0 -j tcp_allowed
Where you add the "banned IP addresses" before the last rule which
is effectively the policy "accept from everyone else" but isn't done
by a default table/chain policy because if we 'accept' the ip address in
this case we need to go back to the "tcp_allowed" chain.
NB. You need to ensure the last rule remains at the end so using
"insert" rather than "append" may well be appropriate.
You can now add/remove rules from the "ftp_check" table at will
without affecting the rest of your setup. You can also choose how
you "reject" the blacklisted ones you can ignore them with "-j DROP"
reject them as above, or use an extended form and reject them
with "host unreachable", "port unreachable" etc. etc.
Mike
----- Original Message -----
From: "Mark Ryan" <markryan@cfl.rr.com>
To: <netfilter@lists.netfilter.org>
Sent: Saturday, January 04, 2003 3:26 PM
Subject: Dynamic Deny rule
> I am trying to come up with a iptables rule that will deny ip certain ip
> addresses that I can load/unload into a file.
>
> To clarify...i run a ftp server and sometimes people screw around and I
> want to ban them from logging in. I need a way to add these ip's into a
> 'ban list'. I don't want to add a new rule every time however with a
> separate rule for each ip.
>
> Is there a way to make a file such as 'banned_ips' and have a rule look
> into that file to decide if the ip can log in or not?
>
> Thanks,
> Mark
>
>
>
>
next prev parent reply other threads:[~2003-01-04 18:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-04 15:26 Dynamic Deny rule Mark Ryan
2003-01-04 18:29 ` Michael J. Tubby B.Sc. (Hons) G8TIC [this message]
2003-01-04 18:53 ` Bob Sully
2003-01-04 21:46 ` Athan
2003-01-04 22:15 ` Bob Sully
2003-01-04 23:10 ` Rob Sterenborg
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='001d01c2b41f$334d8760$0a90a8c0@boris' \
--to=mike.tubby@thorcom.co.uk \
--cc=markryan@cfl.rr.com \
--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;
as well as URLs for NNTP newsgroup(s).