+ Reply
Results 1 to 2 of 2

Your favorite Apple, iPhone, iPad, iOS, Jailbreak, and Cydia site.


Thread: Overriding DNS with /etc/hosts?

is a discussion within the

File Mods

forums, a part of the

iPhone Modding

section;
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
...
  1. #1
    tji
    tji is offline
    What's Jailbreak?
    Join Date
    Sep 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Overriding 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?

  2. #2
    Green Apple
    Join Date
    Jun 2007
    Location
    Baltimore
    Posts
    78
    Thanks
    4
    Thanked 3 Times in 2 Posts

    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:

    127.0.0.1 crazydomain

    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.

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts