Report this

What is the reason for this report?

Help with IPtables causing disconnection and blocking

Posted on January 3, 2016

For some reason my iptables are causing problems for yum. Even more stranger, when I run “iptables -F” to flush the chain, it disconnects me and refuses connection on any port from any ip address. After a force reboot from the control panel, then it allows me to reconnect.

Chain INPUT (policy DROP) ACCEPT TCP DPT:80 ACCEPT TCP DPT:21

Chain FORWARD (policy DROP)

Chain OUTPUT (policy ACCEPT)



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

By running iptables -F you are ‘flushing’ the rules, not affecting the default policy. In your case, it is set to ‘DROP’ which means that, now that all the rules are gone, all packets will be dropped.

You’d want to run iptables -X afterwards to reset everything else to the defaults. So

iptables -F
iptables -X

should allow everything to go through.

What errors do you get when you try to use yum with your IPTables rules enabled? Can you post the output of:

sudo iptables -L -n
sudo iptables-save

I would personally change the default policy to ALLOW then append a DROP at the end of your INPUT Chain, so for instances like what you described when you flush the rules you aren’t locked out.

I would also add a couple of rules in at the front of your INPUT Chain so your iptables-save looks like below

-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -j DROP

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.