ASN-Script: IPFire, iptables und AFWall+
Im April 2017 hatte ich ein Skript gebaut, dass automatisch IP-Adressblöcke auf Basis von ASN-Informationen erzeugt. Der Ursprung dieses Skripts liegt in einem älteren Beitrag, den ihr nochmal lesen solltet: »Google und Facebook IP-Adressen blockieren«.
maloe hat dieses Skript jetzt nochmal erweitert und daraus ein Schweizer-Taschenmesser gebastelt, das für die IPFire, iptables und AFWall+ einsetzbar ist. Ihr findet das Skript hier. Eine Hilfestellung wird es dazu jetzt erstmal nicht geben, da ich das Skript nochmal ausführlich in einem Beitrag vorstellen möchte. Das Skript ist für all jene gedacht, die es (auf eigene Gefahr) testen möchten.
Unter Linux lässt es sich ganz einfach über das Terminal ausführen und hat sogar eine Hilfefunktion mit an Bord:
bash asn_ipfire_beta.sh --help
Output der Hilfe:
Usage: asn_ipfire.sh [OPTION] [COMPANYs | -f FILE] Add or remove networks to IPFire firewall Groups: Networks & Host Groups Options: -a, --add Add new company networks -r, --remove Remove company networks from customnetworks & customgroups COMPANY='ALL' to remove all entries done by this script -f, --file FILE Get company list from FILE -l, --list List entries done by this script --renumber Renumber lines of customnetworks & customgroups files -h, --help Show this help Create special output files (Non-IPFire-Mode): --network Create FILE 'network_list.txt' with networks --network_raw dito, but networks not consolidated --asn Create FILE 'asn_list.txt' with ASNs only --iptable Create FILE 'iptable_rules.txt' with iptable rules --afwall Create FILE 'afwall_rules.txt' with afwall rules COMPANY to be one or more company names, put into double quotes ('"') Multi company names can be comma or space separated usage example: asn_ipfire.sh -a "CompanyA CompanyB CompanyC" asn_ipfire.sh --asn "CompanyA,CompanyB,CompanyC" FILE = name of a file, containing one or more company names. Company names to be separated by space or line feeds. usage example: asn_ipfire.sh -u -f company.lst asn_ipfire.sh --network -f company.lst Notes: Company names are handled case insensitive. Only entries made by asn_ipfire.sh are updated or removed. These entries are recognized by the 'Remark'-column in IPFire.
Und noch ein kleines Beispiel für Android AFWall+ Nutzer, um sich Blockierregeln für Google und Facebook erstellen zu lassen:
bash asn_ipfire_beta.sh --afwall "Google Facebook"
Viel Spaß beim Testen!
Hinweis: Wer Ideen zur weiteren Optimierung hat oder Fehler findet, der möge mich einfach kontaktieren. Die Nutzung erfolgt auf eigene Gefahr!