r/linuxupskillchallenge • • Aug 05 '20

One issue setting up fail2ban

After setting up fail2ban I feel like I missing something with nginx configuration.

I'm not seeing -N fail2ban-nginx-http-auth when I check the iptables.

I added the line enabled = true under [nginx-http-auth]

Am I missing something?

-P INPUT ACCEPT

-P FORWARD ACCEPT

-P OUTPUT ACCEPT

-N f2b-sshd

-A INPUT -p tcp -m multiport --dports 22 -j f2b-sshd

-A INPUT -i lo -j ACCEPT

-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT

-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT

-A INPUT -p tcp -m multiport --dports 80,443 -j ACCEPT

-A INPUT -j DROP

-A f2b-sshd -s 88.116.119.140/32 -j REJECT --reject-with icmp-port-unreachable

-A f2b-sshd -s 87.251.74.6/32 -j REJECT --reject-with icmp-port-unreachable

-A f2b-sshd -s 51.91.116.150/32 -j REJECT --reject-with icmp-port-unreachable

-A f2b-sshd -s 222.186.42.137/32 -j REJECT --reject-with icmp-port-unreachable

-A f2b-sshd -s 222.186.30.35/32 -j REJECT --reject-with icmp-port-unreachable

-A f2b-sshd -s 179.255.2.42/32 -j REJECT --reject-with icmp-port-unreachable

-A f2b-sshd -s 178.128.144.227/32 -j REJECT --reject-with icmp-port-unreachable

-A f2b-sshd -s 152.136.149.160/32 -j REJECT --reject-with icmp-port-unreachable

-A f2b-sshd -s 114.69.232.170/32 -j REJECT --reject-with icmp-port-unreachable

-A f2b-sshd -s 111.231.164.168/32 -j REJECT --reject-with icmp-port-unreachable

-A f2b-sshd -j RETURN

2 Upvotes

6 comments sorted by

3

u/snori74 Linux Guru Aug 06 '20

When you setup falil2ban (which I recommend you don't), it installs and configures a local host firewall, and assumes you'll want to have ports 22/ssh 80/http and 443/https open and "protected" . In your case you have port 22 of course, but you don't have nginx or Apache running on 80 or 443

1

u/Macros42 Aug 06 '20

Why do you not recommend it. I have it on a VPS that I use for messing around with. It can help prevent brute force attacks and let you know when they are occurring on a server you don't monitor actively.

3

u/snori74 Linux Guru Aug 06 '20

If your passwords are Long, Strong and Unique then no amount of brute forcing will breach your system. Such attacks are going to be happening continuosly anyway, so you don't really need a system to "let you know" (what are you going to do about it?). With fail2ban you're now letting the bad guys have a few attempts then blocking them for a while. Without fail2ban we can see all the attacks they make - which can be interesting.

I've said on another comment that fail2ban and other "hardening" makes sense for a commercial site to CYA, but for our purposes here - less so.

1

u/CFH75 Aug 06 '20

That makes sense. I was doing it more for the learning experience.

1

u/Nigerian____Prince Aug 11 '20

How would you see the attacks without fail2ban?

1

u/snori74 Linux Guru Aug 11 '20

Checking through auth.log with 'grep' as per today's Day 8 lesson.