0

can anyone spot what is wrong with this? As soon as I run the script i'm locked out of my server and need to restart it. It's blocking ssh at a minimum. I'm using port 6789 for ssh.

Thanks for any help.

http://pastebin.com/WghZ9yYM

1 Answer 1

3

According to the CentOS documentation, they say

IMPORTANT: At this point we are going to clear the default rule set. If you are connecting remotely to a server via SSH for this tutorial then there is a very real possibility that you could lock yourself out of your machine. You must set the default input policy to accept before flushing the current rules, and then add a rule at the start to explicitly allow yourself access to prevent against locking yourself out.

So you need to set INPUT to Allow. Flush the rules. Add your SSH ALLOW rule, then set INPUT to DROP. So in your case, you can probably change line 12 to ALLOW and move it up before you flush your rules, than at the very end of the script before you finalize everything, put $IPTABLES -P INPUT DROP.

http://wiki.centos.org/HowTos/Network/IPTables

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .