The script below should do what you need. Note that the name of the file from which you'll read the IPs is ips.txt in the script. You can replace it with your own file name.
#!/bin/bash
ip_addresses=$(cat ips.txt)
echo -n "" > iptables_configuration
echo "*raw" >> iptables_configuration
echo ":PREROUTING ACCEPT [0:0]" >> iptables_configuration
echo ":OUTPUT ACCEPT [0:0]" >> iptables_configuration
for i in $ip_addresses
do
echo -A PREROUTING -d $i/32 -j DROP >> iptables_configuration
done
echo "COMMIT" >> iptables_configuration
echo "*filter" >> iptables_configuration
echo ":INPUT ACCEPT [0:0]" >> iptables_configuration
echo ":FORWARD ACCEPT [0:0]" >> iptables_configuration
echo ":OUTPUT ACCEPT [0:0]" >> iptables_configuration
echo "-A INPUT -p tcp -m tcp --dport 25565 --tcp-option 8 --tcp-flags FIN,SYN,RST,ACK SYN -j REJECT --reject-with icmp-port-unreachable" >> iptables_configuration
echo "COMMIT" >> iptables_configuration
cat iptables_configuration | iptables-restore
rm iptables_configuration
iptables -t raw -A PREROUTING -p tcp --dport 25565 -j ACCEPT
iptables -t raw -A PREROUTING -p tcp --dport 25565 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -t raw -A PREROUTING -p tcp --dport 25565 --tcp-flags FIN,SYN,RST,ACK SYN -m connlimit --connlimit-above 150 --connlimit-mask 32 --connlimit-saddr -j DROP
iptables -t raw -A PREROUTING -p tcp --dport 25565 --tcp-flags FIN,SYN,RST,ACK SYN -m connlimit --connlimit-above 10 --connlimit-mask 32 --connlimit-saddr -j DROP
All you have to do is to execute the script where the ips.txt file is present. The rest will be handled by the script.