Re: IP Banning (Using IPFW)



I was wondering if there's some sort of port available that can actively ban IPs that try and bruteforce a service such as SSH or Telnet, by scanning the /var/log/auth.log log for Regex such as "Illegal User" or "LOGIN FAILURES", and then using IPFW to essentially deny (ban) that IP for a certain period of time or possibly forever.

I've seen a very useful one that works for linux (fail2ban), and was wondering if one exists for FreeBSD's IPFW?

There are some in the ports, but you can write your own pretty easy too. The one thing I didn't like about the ones in the ports is the app was responsible for removing the rules after a set amount of time. Which could be a problem if that app crashed for some reason. You could lock yourself out permanently...

Here's a quick perl script I wrote that does what you want...

http://pastebin.com/540575

Combine that with these two crontab entries:

0-59/4 * * * * /sbin/ipfw delete 501 >/dev/null 2>&1
2-59/4 * * * * /sbin/ipfw delete 500 >/dev/null 2>&1

-philip
_______________________________________________
freebsd-questions@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: Questions about ICMP
    ... UDP ports can only be tested by UDP packets, and TCP ports can only be tested by TCP packets. ... ICMP is a different IP protocol which doesn't feature numbered ports. ... This is the generic part of the ipfw ruleset, I am now using on the OS X ... # Deny and log spoofed traffic ...
    (Fedora)
  • problem in smtp server
    ... FTP and the e-mail for the domain with qmail. ... All seems to work fine if i disable the ipfw... ... $cmd 00010 allow all from any to any via lo0 ... $cmd 00299 deny log all from any to any out via $pif ...
    (comp.unix.bsd.freebsd.misc)
  • Re: ipfw question (ip vs tcp)
    ... The ipfw file has a line like this in it: ... > Either way I can then have full user ftp sessions with this server. ... Since the second channel runs on random ports, it is often quite hard to get an FTP session working ... Configure the firewall to allow the same range incoming. ...
    (comp.unix.bsd.freebsd.misc)
  • Trouble with ipfw :( help!
    ... I have configured ipfw on my mail server... ... 00200 deny ip from any to 127.0.0.0/8 ... 00800 allow tcp from any to me dst-port 25,110,995,143,993 setup ...
    (freebsd-questions)
  • IPFW, NATd, dnscache problems
    ... I can't for the life of me get port forwarding setup. ... part is that ipfw is seeing the request come in (the appropriate rule's ... interface dc0 ... ipfw -q add 00301 deny log all from any to 127.0.0.0/8 ...
    (comp.unix.bsd.freebsd.misc)