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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I've had thousands of attempted breakins from a couple of IPs. When I investigate the IP, I see they are definitely on the naughty list.
It looks like I can block them using:
/sbin/iptables -A INPUT -s BAN-IP-ADDRESS -j DROP
/sbin/iptables -A INPUT -s BAN-IP-ADDRESS/MASK -j DROP
PS. What is the "MASK" part all about?
Yes, I know if my server is perfectly configured, I probably don't have anything to worry about. Try as I might, I am concerned that maybe I didn't do something perfect.
PS. Is there an online service that I can have interrogate my IP and look for holes?
So, instead of waiting for thousands of attempted breakins, am I able to subscribe to some service which automatically adds IPs that have been previously known to be malicious? I am not worried about accidentally blocking good guys as the server is only accessed by me (I don't wish to whitelist as I often access the server remotely from different IPs).
While I don't know of any global list you could use, have you looked into denyhosts? It monitors your /var/log/messages or /var/log/secure log files for failed access attempts and adds them to hosts.deny automatically. You can configure it to be a permanent ban, a temporary ban that lasts for N days, you can configure the number of failed attempts in a given amount of time for the IP to be banned, and it can treat root login attempts and user login attempts differently as well.
I run it on my home server, and over the last ~3 months (since I re-installed the OS) it's already added over 300 IPs to the ban list. I'll paste them below if you're interested.
One of the nice things about how it works is that if it adds an IP by mistake, all you have to do is put that IP in hosts.allow to whitelist it.
Every once in a while I'll get bored and start investigating some of them. So far they all seem to be from Russia or China. Probably some 13 year old idiot wannabe "hackers" running a pre-canned script to try and brute-force root access via ssh.
Last edited by suicidaleggroll; 10-24-2014 at 01:41 PM.
I also found denyhosts very useful. One additional measure is to use a non standard port for ssh. You could just forward a different port (say 1234) on your router to port 22 on the PC. This makes /etc/hosts.deny a bit shorter.
once the IP is added to hosts.deny it will be blocked for all services.
...note this only works for services that are compiled with libwrap. Also see this and this.
Originally Posted by NotionCommotion
fail2ban is more wide reaching (and probably more complicated).
That's a misconception. Fail2ban comes with default filters for over 60 services, works with minimal configuration, works at the network level and can use ipset (meaning you only need one iptables rule!).