Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
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 am constantly being attacked by scripted kiddies trying to gain access through SSH. I would like to add a statement in my firewall via IPTABLES to restricting SSH access from untrusted hosts via iptables. I would like a statement that would only allow the IP address that I specify are legitiment or a certain range of IPs that can access my linux box via SSH. Any recommendations?
I an tired of seeing these script kiddie attempts in my var/log/messages. By adding this firewall script or just that statement will it end the var/log/messages entries of these attempts or will I always see these attempts from these idiots?
If your key authentication is working correctly (and I hope it is) this isn't 100% necessary. But it never hurts to be a little more safe...
You could just setup sshd to allow only connections from specific ip addresses/blocks. That could be achieved by adding something like the following to /etc/hosts.allow:
Code:
sshd: <ip1> <ip2> : deny
Or you could incorporate some dynamic blacklisting. There's a script called SSHblack that (which a little tweaking) should accomplish this. I would read the sticky at the top of this group if you haven't already. The link is in there, along with alot of good info.
Well I'm only new to iptables/ipchains myself, I have never used the iptables-save command before, some of these rules don't look right to me. Have you create your own script with all the iptables rules in it? Most distros will have a script usually in the /etc/rc.d directory that runs when the pc boots up.
Most of the time it will be called rc.firewall or something similiar. I notice you have INPUT, FORWARD and OUTPUT rules set to ACCEPT, that's not a good idea very insecure, atleast have your INPUT and FORWARD rules set to DROP, you can have the OUTPUT rules set to ACCEPT.
Some of your INPUT rules are not specifying what input device they are comming in on. Also the FORWARD can say what device they are coming in on, but you are better to specify what device you are forwarding too.
The -p tcp I understand that, but not -m tcp but as I said I'm only new to this so I might be missing something.
I'm currently working on my own iptables script that I'm testing on my test router at home, would be glad to post it to give some ideas on how the rules should look.
Here it is, it is only experimental at the moment but seems to work fine, I haven't had anyone look at it and let me know I'm on the right track with the rules. There is a lot of logging in the script, maybe too much of it for some people, half the script was sourced from different places on the net, the rest I wrote myself.
My beleif is you can never have too much logging, have to know what's coming in or out, one thing I like about the script is it filters tcp coming into and out of the network, which will help to reduce malicious activity in both directions. If you need me to explain any part of the script if you have trouble with it just ask.
Ok i tried to post it but the scripts to long to go on the forum so I link it from my website, just get it from here:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.