If you have a jailbroken iPhone or iPod Touch, it is quite simple to block many advertisement sites from being displayed either in your Safari browser, or in various apps which may have a small section on the screen reserved for littering annoying and flashing ads. This is done by updating your device’s hosts file as described on the “Blocking Unwanted Parasites with a Hosts File” site.

Your device is just like a tiny computer, running the Linux OS (Darwin). And just like other Linux and UNIX operating systems, it contains a /etc/hosts file.

In order to change this file, you need to ssh from a computer to your iPhone or iPod Touch. This requires sshd to be installed on your devices, which you can easily download and install from Cydia.

For instance say your device’s IP is, you log on like this:

$ ssh -l root
root@'s password: 
myipod:~ root# cd /etc
myipod:/etc root# vim hosts

Snippet of hosts file:

# Host Database
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##       localhost broadcasthost
::1             localhost
fe80::1%lo0     localhost

#start of lines added by WinHelp2002
# [Misc A - Z]  fr.a2dfp.net  m.fr.a2dfp.net  ad.a8.net  asy.a8ww.net  abcstats.com  a.abv.bg  adserver.abv.bg  adv.abv.bg  bimg.abv.bg
. . .  www.stickylogic.com  www.winadiscount.com #[Dr.Web.Adware.Xbarre]  www.winaproduct.com
#end of lines added by WinHelp2002

The default root password is “alpine” but with the passwd command you can change it.

Once you are logged on to the device, you can use vim or any other text editor (install via Cydia) to modify the hosts file. You can download one from http://winhelp2002.mvps.org/hosts.htm or make up your own. Then copy/paste it into the hosts file you have open on the device and save it.

Make sure at least the following lines are in the hosts file, otherwise bad things may happen:       localhost broadcasthost
::1             localhost
fe80::1%lo0     localhost

One Reply to “How to block ads on jailbroken iPhone/iPod Touch”

  1. Koen, you can accomplish the same by installing the sbsettings toggle called “sbadblocktoggle”, installable from the Xsellize Cydia repository. That one will automatically install an Iphone optimised hosts file. I’ve been using it for two years now with great satisfaction, haven’t had an add since.
    Groeten, Wouter – Expat TV Vlaanderen

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.