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!
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.
By having your defaults set to ACCEPT, absolutely EVERYTHING not explicitly dropped is being allowed. It should be the other way around. You should drop everything and only allow the traffic you want.
Now with that said, its really not clear which combination of rules is causing the trouble. Certainly allowing port 22 on the INPUT chain is required, but this line:
Is likely to be useless. The SSH server is listening on port 22, but you really have no idea what port the SSH client is using. It may very well not be port 22. I'm guessing that all the other stuff your dropping is causing the problem. I'm guessing that since you're dropping all sorts of syn packets, that is preventing SSH from working properly. Believe it or not, syn packets are required for TCP/IP to work, so dropping random port ranges is probably not a good idea.
-A RH-Lokkit-0-50-INPUT -p tcp --dport 22 -j ACCEPT
COMMIT
and after I restart iptables, I got following results:
# service iptables restart
Flushing all current rules and user defined chains: [ OK ]
Clearing all current rules and user defined chains: [ OK ]
Applying iptables firewall rules: iptables-restore v1.2.7a: no command specified
Try `iptables-restore -h' or 'iptables-restore --help' for more information.
[FAILED]
I'm not sure what tool you would use to modify your firewall (posting your distro might help) but you're probably looking for a firewall that looks something like this:
Code:
iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
This firewall is oversimplified, but maybe it will help you see where to go. Notice that the table defaults are all set to DROP. Then I've allowed ESTABLISHED and RELATED packets in. That allows returned packets from any process originating on my machine to come back. The OUTPUT chain is pretty wide open.
The port 22 rule should let in SSH traffic (it would be NEW, so it would fail the ESTABLISHED and RELATED input rule) and the existing OUTPUT would let the traffic back out.
I really think that your existing firewall is a mess, and it is likely causing problems. If I were in your shoes, I would ditch it entirely and get one in place that you do understand.
I really think that your existing firewall is a mess, and it is likely causing problems. If I were in your shoes, I would ditch it entirely and get one in place that you do understand.
Ok, man. I agree with you. Could you please teach how to ditch it out and patch a new one?
I gather that you're using some flavor of Red Hat/Fedora and I believe that their firewall is controlled by some GUI tool. How did you get your existing firewall? It doesn't look like a default set of rules, so the same way you created this one should let you create a better set of rules. Knowing what distro you're actually using might help us point you in the right direction.
And you're trying to use this as a server exposed to the Internet???????????
A piece of friendly advice: Ditch this distro NOW if not sooner. RH9 has not had any support for a number of years, and there are many, many, many security holes in it. All you're doing with this box is making some botnet owner very happy because they will have another easy-to-crack machine available.
Ah, good. As a learning tool, RH9 is probably OK. I'd still give some thought to grabbing a newer distro as RH9 is pretty dated.
If you don't know or can't find the RH9 firewall GUI tool, you could always write your own firewall script and then run that. As long as you run it at the end of the RH9 boot, it should replace the default firewall.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.