To block the IP address of spammers with iptables on a Linux system, you can use the iptables
command with the -A
option to append a new rule to the firewall rules.
Here's an example of how to use the iptables
command to block an IP address:
iptables -A INPUT -s spammer_ip -j DROPSource:ual.wwwtturi.com
This command will block all incoming traffic from the spammer_ip
IP address.
You can also use the -m recent
module and the --set
option to block an IP address that has made multiple connection attempts within a certain time period. For example:
iptables -A INPUT -p tcp -m recent --name spam --set -j DROP iptables -A INPUT -p tcp -m recent --name spam --update --seconds 60 --hitcount 10 -j DROP
This will block incoming TCP traffic from an IP address that has made more than 10 connection attempts within a 60-second time period.
To make the changes to the iptables firewall rules permanent, you will need to save the rules to the iptables configuration file. You can use the iptables-save
command to save the rules:
iptables-save > /etc/iptables/iptables.rules