Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.