how to write iptable block rule in the /etc/iptables/rules.v4?

  • Posted on January 23, 2015
  • elearnAsked by elearn

I can block some ip to link my vps in command line : sudo iptables -A INPUT -s [IP ADDRESS] -j DROP

how to write the iptable block rule in the /etc/iptables/rules.v4?

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

sudo dpkg-reconfigure iptables-persistent can do .

root@change:~# sudo iptables -A INPUT -s -j DROP root@change:~# cat /etc/iptables/rules.v4

Generated by iptables-save v1.4.14 on Fri Jan 23 12:42:00 2015

*filter :INPUT ACCEPT [415:61359] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [398:101696] COMMIT

Completed on Fri Jan 23 12:42:00 2015


Why there is no in the file /etc/iptables/rules.v4?

You can run the following command to save the current rules in /etc/iptables/rules.v4 and /etc/iptables/rules.v6:

sudo service iptables-persistent save