kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: Keh-Ming Luoh <kmluoh@gmail.com>
To: noloader@gmail.com
Cc: kernelnewbies <kernelnewbies@kernelnewbies.org>
Subject: Re: iptables and combining additional rule sources
Date: Fri, 24 Apr 2020 20:32:35 -0700	[thread overview]
Message-ID: <CAL1wv4Qe85L94De2hn9v_EX7Zh=RU0J-kwSUJj+6kBdrEJYm3g@mail.gmail.com> (raw)
In-Reply-To: <CAH8yC8kqc=HUGs=nUbe52anfT24CGyS0VypCpuqNZNPb6gcB6g@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 2407 bytes --]

Assuming these IP address are treated the same way in your iptables rule,
ipset may help to make it simpler.



On Fri, Apr 24, 2020 at 3:30 PM Jeffrey Walton <noloader@gmail.com> wrote:

> Hi Everyone,
>
> We are having trouble with our MediaWiki installation on a low-end VM.
> The VM is servicing a lot of spam traffic, and it is driving cpu usage
> up to about 80%. The 404's appear to be more expensive then the 200's.
> GoDaddy wrote to us and told us they were going to suspend our service
> if we don't get cpu usage down.
>
> I experimented with several Apache and MediaWiki plugins and I have a
> design I like. The plugin scans the URL, detects the problematic URLs,
> and sends the ip address to a privileged out-of-proc proxy to update
> iptables. The proxy is privileged and can update iptables rules. It
> also maintains a database to remove the host after 45 days.
>
> The problem I am having is, adding the new information to the existing
> iptables rules in /etc/sysconfig/iptables. I want to write my rules to
> a separate file and then tell /etc/sysconfig/iptables to include it at
> the correct position.
>
> I read the iptables(8), iptables-save(8) and iptables-restore(8) man
> pages, but I don't see how to combine the different sources.
>
> How do I tell iptables to include a second external source at a
> specific location?
>
> # iptables --version
> iptables v1.4.21
>
> Thanks in advance.
>
> =========================
>
> Here is an example of /etc/sysconfig/iptables with the position I want
> to insert the MediaWiki ban rules.
>
> # cat /etc/sysconfig/iptables
> *nat
> :PREROUTING ACCEPT [4276:232374]
> :POSTROUTING ACCEPT [270:136514]
> :OUTPUT ACCEPT [270:136514]
> COMMIT
>
> *filter
> :INPUT ACCEPT [0:0]
> :FORWARD ACCEPT [0:0]
> :OUTPUT ACCEPT [269:205262]
>
> -A INPUT -p icmp -j ACCEPT
> -A INPUT -i lo -j ACCEPT
>
> ### I want to insert rules here ###
> *include my-mediawiki-rules
>
> ### Back to normal rules ###
> -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
> -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
> -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
> -A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
> ...
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>

[-- Attachment #1.2: Type: text/html, Size: 3113 bytes --]

[-- Attachment #2: Type: text/plain, Size: 170 bytes --]

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

  parent reply	other threads:[~2020-04-25  3:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-24 22:28 iptables and combining additional rule sources Jeffrey Walton
2020-04-25  3:06 ` Valdis Klētnieks
2020-04-25  6:55   ` Jeffrey Walton
2020-04-25 16:53     ` Valdis Klētnieks
2020-04-25 17:16       ` Jeffrey Walton
2020-04-25  3:32 ` Keh-Ming Luoh [this message]
2020-04-25  7:01   ` Jeffrey Walton
2020-04-26 12:42 ` Aruna Hewapathirane
2020-04-29  9:30 ` Thorondir

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='CAL1wv4Qe85L94De2hn9v_EX7Zh=RU0J-kwSUJj+6kBdrEJYm3g@mail.gmail.com' \
    --to=kmluoh@gmail.com \
    --cc=kernelnewbies@kernelnewbies.org \
    --cc=noloader@gmail.com \
    /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).