BASH IP Tables
From Indie IT Wiki
IPTABLES:
Allow PING ICMP
iptables -A INPUT -p icmp -j ACCEPT
Online Generator
https://www.perturb.org/content/iptables-rules.html
Docker SMTP Block IP Address
You need to insert your rule above the RETURN all rule at point # 1.
List your rules...
iptables -L DOCKER-USER --line-numbers Chain DOCKER-USER (1 references) num target prot opt source destination 1 RETURN all -- anywhere anywhere
Then insert your rule at point # 1...
iptables --insert DOCKER-USER 1 --protocol tcp --src 31.210.20.130 --dst ip-172-20-0-2.eu-west-2.compute.internal --dport 25 --jump DROP
Then check your rules again...
iptables -L DOCKER-USER --line-numbers Chain DOCKER-USER (1 references) num target prot opt source destination 1 DROP tcp -- 31.210.20.130 ip-172-20-0-2.eu-west-2.compute.internal tcp dpt:smtp 2 RETURN all -- anywhere anywhere
Done.
https://docs.docker.com/network/iptables/
Use IPTables Firewall To Block An IP Address
For a single IP address...
iptables -I INPUT -s 123.45.67.89 -j DROP
For a range of IP addresses...
iptables -I INPUT -s 123.45.67.0/24 -j DROP
Use IPTables To List A Blocked IP Address
iptables -L INPUT -v -n
iptables -S
iptables -L INPUT --line-numbers
Thanks to Cyberciti
Thanks to Cyberciti
Use IPTables To Edit / Delete A Chain Rule
List the rules of the Chain first...
iptables -L INPUT --line-numbers
...then delete the Number you want to clear...
iptables -D INPUT 4
Use IPTables To Delete ALL Rules
Thanks to Cyberciti