Another option here is to have your iPhone connect via a proxy. Here’s an example of how to do it with Fiddler (it’s very easy):
http://conceptdev.blogspot.com/2009/01/monitoring-iphone-web-traffic-with.html
[external_link_head]In that case any dns lookups your iPhone does will use the hosts file of the machine Fiddler is running on. Note, though, that you must use a name that will be resolved via DNS. example.local
, for instance, will not work. example.xyz
or example.dev
will.
caramba
20.4k18 gold badges80 silver badges121 bronze badges
answered Jun 17 ’11 at 12:49
stubotnikstubotnik
1,9422 gold badges17 silver badges31 bronze badges
12
This doesn’t directly answer your question, but it does solve your problem…
What make of router do you have? Your router firmware may allow you to set DNS records for your local network. This is what I do with the Tomato firmware
answered Jan 8 ’10 at 15:41
Andrew BullockAndrew Bullock
34.6k32 gold badges148 silver badges220 bronze badges
[external_link offset=1]3
Not programming related, but I’ll answer anyway. It’s in /etc/hosts
.
You can change it with a simple text editor such as nano
.
(Obviously you would need a jailbroken iphone for this)
answered Jan 8 ’10 at 15:29
Thomas BoniniThomas Bonini
41.2k29 gold badges117 silver badges155 bronze badges
7
I just edited my iPhone’s ‘hosts’ file successfully (on Jailbroken iOS 4.0).
- Installed OpenSSH onto iPhone via Cydia
- Using a SFTP client like FileZilla on my computer, I connected to my iPhone
- Address: [use your phone’s IP address or hostname, eg.
simophone.local
] - Username:
root
- Password:
alpine
- Address: [use your phone’s IP address or hostname, eg.
- Located the
/etc/hosts
file - Made a backup on my computer (in case I want to revert my changes later)
- Edited the hosts file in a decent text editor (such as Notepad++). See here for an explanation of the hosts file.
- Uploaded the changes, overwriting the hosts file on the iPhone
The phone does cache some webpages and DNS queries, so a reboot or clearing the cache may help. Hope that helps someone.
Simon.
answered Sep 20 ’10 at 3:08
Simon EastSimon East
47.9k15 gold badges130 silver badges126 bronze badges
3
It might exist, but you cannot change it on a non-jailbreaked iPhone.
Assuming that your development webserver is on a Mac, why don’t you simply use its Bonjour name (e.g. MyMac.local.
) instead of myrealwebserverontheinternet.com
?
answered Jan 8 ’10 at 15:37
oefeoefe
17.5k7 gold badges41 silver badges66 bronze badges
1
Don’t change the DNS on the phone. Instead, connect with wifi to the local network and you are all set.
At my office, we have internal servers with internal DNS that are not exposed to the Internet. I just connect with iPhone to the office wifi and can then access them fine.
[external_link offset=2]YMMV, but instead of configuring the phone DNS, it feels to me that just setting up local internal DNS and wifi is a cleaner and easier solution.
answered Jan 8 ’10 at 19:36
JaanusJaanus
17.3k14 gold badges62 silver badges104 bronze badges
In case anybody else falls onto this page, you can also solve this by using the Ip address in the URL request instead of the domain:
NSURL *myURL = [NSURL URLWithString:@"http://0908603917/mypage.php"];
Then you specify the Host manually:
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:myURL]; [request setAllHTTPHeaderFields:[NSDictionary dictionaryWithObjectAndKeys:@"myserver",@"Host"]];
As far as the server is concerned, it will behave the exact same way as if you had used http://myserver/mypage.php
, except that the iPhone will not have to do a DNS lookup.
100% Public API.
answered Dec 12 ’11 at 19:14
ekscryptoekscrypto
3,5191 gold badge21 silver badges36 bronze badges
3
No, an iPhone application can only change stuff within its own little sandbox. (And even there there are things that you can’t change on the fly.)
Your best bet is probably to use the servers IP address rather than hostname. Slightly harder, but not that hard if you just need to resolve a single address, would be to put a DNS server on your Mac and configure your iPhone to use that.
answered Jan 8 ’10 at 15:37
Stephen DarlingtonStephen Darlington
49.9k11 gold badges102 silver badges148 bronze badges
Not the answer you’re looking for? Browse other questions tagged iphone dns hosts-file or ask your own question.
[external_footer]