<div dir="ltr">Assuming these IP address are treated the same way in your iptables rule, ipset may help to make it simpler.<div><br><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Apr 24, 2020 at 3:30 PM Jeffrey Walton <<a href="mailto:noloader@gmail.com">noloader@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Everyone,<br>
<br>
We are having trouble with our MediaWiki installation on a low-end VM.<br>
The VM is servicing a lot of spam traffic, and it is driving cpu usage<br>
up to about 80%. The 404's appear to be more expensive then the 200's.<br>
GoDaddy wrote to us and told us they were going to suspend our service<br>
if we don't get cpu usage down.<br>
<br>
I experimented with several Apache and MediaWiki plugins and I have a<br>
design I like. The plugin scans the URL, detects the problematic URLs,<br>
and sends the ip address to a privileged out-of-proc proxy to update<br>
iptables. The proxy is privileged and can update iptables rules. It<br>
also maintains a database to remove the host after 45 days.<br>
<br>
The problem I am having is, adding the new information to the existing<br>
iptables rules in /etc/sysconfig/iptables. I want to write my rules to<br>
a separate file and then tell /etc/sysconfig/iptables to include it at<br>
the correct position.<br>
<br>
I read the iptables(8), iptables-save(8) and iptables-restore(8) man<br>
pages, but I don't see how to combine the different sources.<br>
<br>
How do I tell iptables to include a second external source at a<br>
specific location?<br>
<br>
# iptables --version<br>
iptables v1.4.21<br>
<br>
Thanks in advance.<br>
<br>
=========================<br>
<br>
Here is an example of /etc/sysconfig/iptables with the position I want<br>
to insert the MediaWiki ban rules.<br>
<br>
# cat /etc/sysconfig/iptables<br>
*nat<br>
:PREROUTING ACCEPT [4276:232374]<br>
:POSTROUTING ACCEPT [270:136514]<br>
:OUTPUT ACCEPT [270:136514]<br>
COMMIT<br>
<br>
*filter<br>
:INPUT ACCEPT [0:0]<br>
:FORWARD ACCEPT [0:0]<br>
:OUTPUT ACCEPT [269:205262]<br>
<br>
-A INPUT -p icmp -j ACCEPT<br>
-A INPUT -i lo -j ACCEPT<br>
<br>
### I want to insert rules here ###<br>
*include my-mediawiki-rules<br>
<br>
### Back to normal rules ###<br>
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT<br>
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT<br>
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT<br>
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT<br>
...<br>
<br>
_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">Kernelnewbies@kernelnewbies.org</a><br>
<a href="https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" rel="noreferrer" target="_blank">https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
</blockquote></div>