This site has a nice iptables script that can be used to block ads on the Internet.
Copy and paste this script into a file named ads in the /etc directory. Then create a script in the network/if-up.d/ directory named iptables and make it executable. Now put this in it.
#!/bin/sh iptables-restore < /etc/ads
This will load the iptables rules into the iptables firewall on each boot. If the iptables script is placed in the if-pre-up.d/ directory instead, the iptables rules will be loaded before the network is connected, which may be desirable depending on the other firewall rules the system administrator is using.