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?
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!
It may not be the easiest way / best way, but I use iptables-persistent to do so Once installed, launch sudo dpkg-reconfigure iptables-persistent to save your iptables
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
root@change:~# sudo iptables -A INPUT -s 193.201.224.186 -j DROP root@change:~# cat /etc/iptables/rules.v4
*filter :INPUT ACCEPT [415:61359] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [398:101696] COMMIT
root@change:~#
Why there is no 193.201.224.186 in the file /etc/iptables/rules.v4?
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
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
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.