Linux – IPTABLES: Flushing & starting from scratch over SSH – VPS – CentOS 5.5 x86_64

centosiptableslinuxsshvps

I have a VPS with a hosting company so I remotely access it via SSH.
I'm trying to flush all the iptables rules and start from scratch… The problem is that when I type # iptables INPUT DROP (as I wan't to block all incoming and whitelist) then PuTTY drops out and I can't connect.

How can I do this without being booted out by CentOS when I type that command.

Or is there another way to do it.

Thanks

Best Answer

You need to make sure that your existing connections stay open when you add that rule.

-A INPUT -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT

Then add your allow list below this, and finally add a drop line to the END of the INPUT chain

-A INPUT -j DROP


A good read/tutorial for you to start with would be: here

Related Topic