Phantomski
Regular Contributor
Hi everyone,
playing a bit with log management / analysis and potential feedback loop to live firewall rules. Call it a poor man tinkerer IDS/IPS
I have a fairly simple setup with RT-AC88U (with Skynet) using port forwarding rules on ports 80 and 443, redirecting to a Docker-ised rPi4 running a reverse proxy container, which then splits my subdomains to various HTTP(S) server containers running various services.
The idea is that I basically look at my webserver logs for fingerprints of malicious activity (WordPress and Router GUI scans are fairly common and easily identified for example) and based on the severity I'd then add an IP ban to the Skynet rules on my router, potentially report the offender to OTX like AlienVault, etc.
Anyway.
Now one thing left me head scratching a bit, as I could not find a definite and concise documentation for a standardised way of doing these things and that's the order of firewall rules.
Looking into my current (more or less factory default + OVPN and few scripts) iptables/IPSet it seems to be the case, that the firewall rules take the precedence over the port forwarding rules. Indeed if I ban an IP, the packets get dropped by firewall first, before having a chance to get forwarded to my local webserver, unlike in the case of let's say DMZ setup. However, that seems to be entirely by chance (uncomfortable feeling) order in iptables, rather than a general rule or a design practice that would apply to routers/firewalls. In other words if it wasn't for Skynet, the port forwarding would happen before the DROP, quite obviously as there's no per-IP IPSet filtering added on top. And if Skynet wasn't a Skynet, one could easily make a mistake of port forwarding first, firewall second. Ouch.
So here comes a question (tada) - is this a standard design practice and I'm just missing something obvious, or was Adamm00 just diligent enough to make it a robust universal solution (inbound is simple, but outbound and special rules are not) that kinda works well because it's always nr.1 rule in the flow? Banning lots of wide IP ranges outright certainly adds to a peace of mind, just want to make sure it is robust enough.
Cheers.
playing a bit with log management / analysis and potential feedback loop to live firewall rules. Call it a poor man tinkerer IDS/IPS
I have a fairly simple setup with RT-AC88U (with Skynet) using port forwarding rules on ports 80 and 443, redirecting to a Docker-ised rPi4 running a reverse proxy container, which then splits my subdomains to various HTTP(S) server containers running various services.
The idea is that I basically look at my webserver logs for fingerprints of malicious activity (WordPress and Router GUI scans are fairly common and easily identified for example) and based on the severity I'd then add an IP ban to the Skynet rules on my router, potentially report the offender to OTX like AlienVault, etc.
Anyway.
Now one thing left me head scratching a bit, as I could not find a definite and concise documentation for a standardised way of doing these things and that's the order of firewall rules.
Looking into my current (more or less factory default + OVPN and few scripts) iptables/IPSet it seems to be the case, that the firewall rules take the precedence over the port forwarding rules. Indeed if I ban an IP, the packets get dropped by firewall first, before having a chance to get forwarded to my local webserver, unlike in the case of let's say DMZ setup. However, that seems to be entirely by chance (uncomfortable feeling) order in iptables, rather than a general rule or a design practice that would apply to routers/firewalls. In other words if it wasn't for Skynet, the port forwarding would happen before the DROP, quite obviously as there's no per-IP IPSet filtering added on top. And if Skynet wasn't a Skynet, one could easily make a mistake of port forwarding first, firewall second. Ouch.
So here comes a question (tada) - is this a standard design practice and I'm just missing something obvious, or was Adamm00 just diligent enough to make it a robust universal solution (inbound is simple, but outbound and special rules are not) that kinda works well because it's always nr.1 rule in the flow? Banning lots of wide IP ranges outright certainly adds to a peace of mind, just want to make sure it is robust enough.
Cheers.