VOOZH about

URL: https://www.digitalocean.com/community/tutorials/how-to-list-and-delete-iptables-firewall-rules?comment=83458

⇱ List and Delete iptables Firewall Rules in Linux | DigitalOcean


πŸ‘ List and Delete iptables Firewall Rules in Linux

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the author(s)

Software Engineer @ DigitalOcean. Former SeΓ±or Technical Writer (I no longer update articles or respond to comments). Expertise in areas including Ubuntu, PostgreSQL, MySQL, and more.

πŸ‘ Anish Singh Walia
Anish Singh Walia
Editor
Sr Technical Content Strategist and Team Lead
See author profile

I help Businesses scale with AI x SEO x (authentic) Content that revives traffic and keeps leads flowing | 3,000,000+ Average monthly readers on Medium | Sr Technical Writer(Team Lead) @ DigitalOcean | Ex-Cloud Consultant @ AMEX | Ex-Site Reliability Engineer(DevOps)@Nutanix

πŸ‘ Manikandan Kurup
Manikandan Kurup
Editor
Senior Technical Content Engineer I
See author profile

With over 6 years of experience in tech publishing, Mani has edited and published more than 75 books covering a wide range of data science topics. Known for his strong attention to detail and technical knowledge, Mani specializes in creating clear, concise, and easy-to-understand content tailored for developers.

Still looking for an answer?

Was this helpful?

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!

This comment has been deleted

Another great tutorial I would like to add that is you want to reduce the number of SSH brute force attacks you can add this CHAIN to your iptables rules. Adjust accordingly to the seconds and hitcount and port for your server.

Create chain for ssh attacks

$ iptables -N SSH_CHECK

$ iptables -I INPUT -p tcp --dport 22 -m state --state NEW -j SSH_CHECK $ iptables -A SSH_CHECK -m recent --set --name SSH $ iptables -A SSH_CHECK -m recent --update --seconds 120 --hitcount 5 --name SSH -j DROP

I locked out myself from ssh ? How do i fix it?

wow… nice, concise, and useful… thank you very much

Great tutorial, it worth to add:

iptables -t nat -X

which will clean chains in nat table too.

Thank you!

I’m having issues deleting a specific rule from my iptables. I used iptables -t nat -S to list the rule: -A POSTROUTING -s 10.8.0.0/24 ! -d 10.8.0.0/24 -j SNAT --to-source 192.168.111.111

and tried to delete it with: $ sudo iptables -D POSTROUTING -s 10.8.0.0/24 ! -d 10.8.0.0/24 -j SNAT --to-source 192.168.111.111 iptables: Bad rule (does a matching rule exist in that chain?).

I’m sure it’s just a syntax issue but I’m having trouble finding a reference that clears it up for me. Any help would be greatly appreciated.

πŸ‘ Creative Commons
This work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.
  • Deploy on DigitalOcean

    Click below to sign up for DigitalOcean's virtual machines, Databases, and AIML products.

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and AI-native businesses

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

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

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

Β© 2026 DigitalOcean, LLC.Sitemap.
Dark mode is coming soon.