*************************
chmod +x adblock.sh
sudo ./adblock.sh -help
*************************
./adblock.sh -domains
: Configure adblock rules based on the domain names of domainNames.txt file
Reads each domain name from the file "domainNames.txt" line by line.
For each domain name finds it's IP addresses using nslookup .
Writes every IP address to the "IPAddresses.txt" file.
Reads every IP address from the "IPAddresses.txt" file element by elemen.
Checks if the IP is in IPv6 form or not and adds new rule(block) for each new IP using
ip6tables -A INPUT -s
./adblock.sh -ips
: Configure adblock rules based on the IP addresses of IPAddresses.txt file
Reads every IP address from the "IPAddresses.txt" file element by element.
Checks if the IP is in IPv6 form or not and adds new rule(block) for each new IP using
ip6tables -A INPUT -s
./adblock.sh -save
: Save rules to adblockRules file using the iptables-save command, saves the rules to adblockRules in current directory
./adblock.sh -load
: Load rules from adblockRules file using the iptables-restore command, loads the rules written on adblockRules file
./adblock.sh -list
: List curent rules of all tables using the iptables -L -v -n|more and ip6tables -L -v -n|more commands respectively, displays all tables rules
./adblock.sh -reset
: Reset rules to default settings - ACCEPT all sets accept all to all connections deletes all existing rules with iptables(and ip6tables) -flush
./adblock.sh -help
: Display options menu and exit
After cofiguring the adblock rules and visiting some sites: I can only see in-video ads on Youtube, but on some sites some ads were not blocked, like pop-ups or some static images. This happens because we haven't block all the ips needed. We blocked 300 IP addresses so it is very possible to still accept some advertising domains.