Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.
Thread: Overriding DNS with /etc/hosts?is a discussion within the
File Modsforums, a part of the
Anyone know how the iPhone is handling DNS queries? Apparently, it's not like in Mac OS X / Unix. In Mac OS, I can add an entry to /etc/hosts, and...
09-18-2007, 04:10 PM #1Overriding DNS with /etc/hosts?
Anyone know how the iPhone is handling DNS queries?
Apparently, it's not like in Mac OS X / Unix. In Mac OS, I can add an entry to /etc/hosts, and it will be used before doing a DNS lookup. When I did that on my iPhone, it didn't effect anything.
What I'm trying to do:
add an entry into /etc/hosts, "127.0.0.1 ad.doubleclick.net", which will cause advertisement banners to be skipped (Safari will try to connect to localhost to get the images, which will fail.) My intent is to make loading a commonly used web site much quicker. It's a site that constantly updates NFL football stats, and every time it refreshes, it loads large doubleclick banner ads. So, if I can get it to skip those, it will refresh faster, save memory, and save network bandwidth.
That method works great on Mac OS X, but on the iPhone it just ignores the /etc/hosts entry, and keeps loading the banner ads. Any thoughts?
09-19-2007, 05:10 AM #2
In all flavors of Unix there is a config file that controls the order in which resources are used to resolve names. There are the three methods.. /etc/hosts, NIS (outdated by DNS but still used on some LANs), and DNS.
Mac OS X has these settings not in a flat file but in the netinfo database. I am not sure if the iPhone has the command line client for netinfo or if it even uses it, but that is what you need to change.
You can test this by coming up with some crazy domain that doesn't exist, and then putting:
in the /etc/hosts.. if it eventually does ping to 127.0.0.1 then you know that the problem is the order in which names get resolved. If DNS is set to be used before /etc/hosts then /etc/hosts will never get used for names that exist.
I had this problem on my Macbook Pro. Somehow Mac OS X came configured in a way where you couldn't override DNS with /etc/hosts, but I changed it in Netinfo. I can't recall the exact method but it's a starting point.