fix
Block Ads On Your Jailbroken iPhone Or iPod Touch
Posted by Kevin Purdy at 3:05 AM on October 9, 2008
Many web pages would load up a heck of a lot faster on the iPhone's Mobile Safari browser if you weren't stuck waiting for "LOWER YOUR INTEREST RATES NOW" and the like to push through on Mobile Safari. If you've jailbroken your iPhone or iPod touch, however, there's a none-too-hard hack you can make to block a good number of ads from slowing down your page loads. Here's the step-by-step instructions for doing so:
- If you haven't done so already, you'll need to jailbreak your iPhone or iPod touch. We've previously posted guides for doing so in Windows with WinPwn, and with the PwnageTool on a Mac.
- Click the Cydia icon on your jailbroken device. Choose the "Search" function from the bottom, and type in "OpenSSH" (without the quotes) until you can see that package. Click it, choose "Confirm" in the upper-right to install, then re-start your device.
- Once your iPhone/touch reboots, head to Settings, then Wi-Fi, then click the arrow next to the Wi-Fi server you use at home. Write down the IP address. Head back to Settings, choose General, and set Auto-Lock to "Never" (for the time being).
- You'll need an FTP client with SFTP (secure SSH connection over FTP) to connect and trade files with your device. Windows users should try the free FileZilla (which also comes in a no-install portable package), and Mac users' best bet is Cyberduck.
- On your computer, download this replacement hosts.php file from the James is Bored site. Open your FTP client, set it to connect over an SFTP connection, and then put your iPhone/touch's IP address in the "host" section. Your username and password (unless you changed them) are
rootandalpine, respectively. The connection may take a few minutes at first, and you may be asked to accept a host key; say yes to any prompts, and be prepared to try again if the connection fails at first. - Navigate to to the
/etcfolder at your device's root. Grab thehosts.phpfile you see there, and place it somewhere secure on your computer (i.e. somewhere it won't get over-written with the James is Bored modified file). This can usually be done in a drag-and-drop fashion. - Copy the modified
hosts.phpfile to your device and replace the version there. Close your FTP client, and restart your iPhone or iPod touch.
You should start seeing blank spaces or compressed frames where ads used to be. This hack will still leave blank spaces where Flash-based ads would normally be, but display ads from a number of common ad servers should be blocked. If anything important gets blocked, you can easily re-copy your original hosts.php file back to your device.
I found a few sites—including the New York Times—where the ad-blocking just didn't seem to work, likely because the ads are served through an in-house server. Other places, it worked liked a charm.
Got another method for scaling back ads on your iPhone? Have a better, compatible hosts file to replace the default with? Tell us about it in the comments.

Comments (AU Comments · US Comments)
There are currently no AU comments for this post.
nffcnnr
Posted 4:38 AM 9/10/08
Now if we can find a way to block Drudge from all of the internets. That would be sweet.
nffcnnr
kamikaze
Posted 4:34 AM 9/10/08
worked like a charm...thanks!
kamikaze
hardman.ethan
Posted 4:31 AM 9/10/08
Whoa, sweet!
Now the internet on the iPod touch will be really WORTH it!! :)
hardman.ethan
eambos
Posted 6:02 AM 9/10/08
It works great, but the only problem is that the QuickGold search/launch becomes disabled because "AdMob" is blocked.
It wasn't too important to me, so I'd rather keep blocking adds.
eambos
Eris
Posted 5:56 AM 9/10/08
Wait, is the file on the iphone really called hosts.php? If it is, that's...bizzarre.
Eris
timofcourse
Posted 5:01 AM 9/10/08
Half of the steps above (steps 2-5) can be skipped entirely if you grab the "iPhone Browser" (for Windows folks that is). The only downside being your iPhone needs to be connected to your PC - and its Windows only. Other than that, it makes transferring files back and forth much easier.
[code.google.com]
timofcourse
Interrupt19
Posted 8:47 AM 9/10/08
This does work well unless you are using jailbroken apps from BigBoss and block AdMob.
The apps know when you disable AdMob in the hosts file and refuse to run.
Interrupt19
KCBlueGal
Posted 8:39 AM 9/10/08
@eambos: Same problem with Categories. You can't load the app if you use Adblocking. I also uninstalled Categories after realizing this when I did the ad-blocking thing last month. Glad I wasn't too attached to it at that point.
KCBlueGal
jopari
Posted 9:57 AM 9/10/08
@Eris: Why? It's running OS X, and OS X uses a hosts.php file.
jopari
RayDelMundo
Posted 9:44 AM 9/10/08
@Eris:
No.
The file is just named hosts.
No extension.
RayDelMundo
qwame
Posted 10:14 AM 9/10/08
@Interrupt19: This was a deal breaker for me, but all you have to do to get around it, is remove the one line near the top, to remove admob from the list. Then save it and upload it, and it should block all of the other ad sites.
qwame
m021478
Posted 10:41 AM 10/10/08
Thanks qwame!! That's a great tip!
...for those who didn't take the time to expand his reply above, just remove the line at the top of the hosts.php file that contains admob, and your ad-support-required apps (such as QuickGold & Categories) will work again, and the new hosts file will still block most of your MobileSafari ads!
m021478