Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a small web-server and wanted to tighten up security by adding some recommended iptable rules online, but this looks dubious.
My question is about the -limit module in iptables in combination with the LOG target.
I understand the drop rules below, but it seems to me that -m limit portions are screwing up the rules.
Code:
$IPT -t mangle -A PREROUTING -p tcp --tcp-flags FIN,RST FIN,RST -m limit --limit 25/min -j LOG --log-prefix "BLOCKING-TCP"
$IPT -t mangle -A PREROUTING -p tcp --tcp-flags FIN,RST FIN,RST -j DROP
$IPT -t mangle -A PREROUTING -p tcp -m conntrack --ctstate NEW -m tcpmss ! --mss 536:65535 -m limit --limit 25/min -j LOG --log-prefix "BLOCKING-TCP"
$IPT -t mangle -A PREROUTING -p tcp -m conntrack --ctstate NEW -m tcpmss ! --mss 536:65535 -j DROP
$IPT -t mangle -A PREROUTING -p tcp --tcp-flags ALL FIN,PSH,URG -m limit --limit 25/min -j LOG --log-prefix "BLOCKING-TCP"
$IPT -t mangle -A PREROUTING -p tcp --tcp-flags ALL FIN,PSH,URG -j DROP
$IPT -t mangle -A PREROUTING -p tcp ! --syn -m state --state NEW -m limit --limit 25/min -j LOG --log-prefix "BLOCKING-TCP"
$IPT -t mangle -A PREROUTING -p tcp ! --syn -m state --state NEW -j DROP
$IPT -t mangle -A PREROUTING -p tcp --tcp-flags ALL ALL -m limit --limit 25/min -j LOG --log-prefix "BLOCKING-TCP"
$IPT -t mangle -A PREROUTING -p tcp --tcp-flags ALL ALL -j DROP
Reading the manpage, the principle of only matching the rule n times and thus only logging it n times is fine, but these rules include special instructions where this cannot work I believe and it will actually interfere with each DROP rule below.
For example this makes perfect sense:
(Logging incoming tcp packets on port 80 / 25 packets per minute, i.e 25 log entries per minute)
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.
This matches your update here from this other thread, please continue in that original thread to avoid confusion.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.