Is there a hosts file on the iPhone? How to change it?

I am developing an application that requests a server. On my Mac, I use the hosts file to change dns to point to a local server on the local LAN.

Now I need to test it with the iPhone, the problem is that my iPhone does not recognize this server due to the lack of configuration for dns.

On my Mac or Windows, I just add: 192.168.0.20 http://www.google.com to the hosts file.

Now, how can I tell my iPhone about the URL: http://www.google.com

+84
iphone dns hosts-file
Jan 08 '10 at 15:27
source share
8 answers

This does not answer your question directly, but it solves your problem ...

What does the router do with you? The firmware of your router may allow you to set DNS records for your local network. This is what I do with Tomato firmware

+33
Jan 08 '10 at 15:41
source share

Another option here is to connect your iPhone through a proxy. Here is an example of how to do this with Fiddler (this is very simple):

http://conceptdev.blogspot.com/2009/01/monitoring-iphone-web-traffic-with.html

In this case, any DNS queries your iPhone makes will use the host file of the Fiddler machine. Note , however, you must use a name that will be resolved through DNS. example.local , for example, will not work. example.xyz or example.dev will be.

+69
Jun 17 2018-11-12T00:
source share

Not related to programming, but I will answer anyway. It is located in /etc/hosts .

You can change it with a simple text editor such as nano .

(Obviously you will need a jailbroken iphone for this)

+28
Jan 08
source share

I just deleted my iOS host file (on Jailbroken iOS 4.0).

  • Installed OpenSSH on iPhone via Cydia
  • Using an SFTP client like FileZilla on my computer, I connected to my iPhone
    • Address: [use your phone’s IP address or hostname, for example. simophone.local ]
    • Username: root
    • Password: alpine
  • The /etc/hosts
  • Created a backup on my computer (in case I want to change my changes later)
  • Edited the hosts file in a decent text editor (e.g. Notepad ++ ). See here for an explanation of the hosts file.
  • Uploaded the changes by overwriting the hosts file on the iPhone

The phone caches some web pages and DNS queries, so reloading or clearing the cache may help. Hope that helps someone.

Simon.

+12
Sep 20 2018-10-10T00:
source share

It may exist, but you cannot change it on an iPhone that has not jailbroken.

Assuming your development web server is on a Mac, why don't you just use its Bonjour name (like MyMac.local. ) Instead of myrealwebserverontheinternet.com ?

+6
Jan 08 '10 at 15:37
source share

In case anyone else gets to this page, you can also solve this problem by using the IP address in the URL instead of the domain:

 NSURL *myURL = [NSURL URLWithString:@"http://10.0.0.2/mypage.php"]; 

Then you specify Host manually:

 NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:myURL]; [request setAllHTTPHeaderFields:[NSDictionary dictionaryWithObjectAndKeys:@"myserver",@"Host"]]; 

As for the server, it will behave exactly as if you were using http://myserver/mypage.php , except that the iPhone will not have to do a DNS lookup.

100% open API.

+5
Dec 12 '11 at 19:14
source share

Do not change the DNS on the phone. Instead, connect to Wi-Fi on the local network and everything will be installed.

In my office, we have internal servers with internal DNS that do not have access to the Internet. I just connect to the iPhone in the Wi-Fi office and can access them.

YMMV, but instead of setting up a DNS phone, it seems to me that just setting up local internal DNS and wifi is a simpler and simpler solution.

+3
Jan 08
source share

No, the iPhone app can only change material in its small sandbox. (And even there are things that you cannot change on the fly.)

It is probably best to use the IP address of the servers rather than the host name. A little harder, but not so difficult, if you just need to solve one address, you would need to host a DNS server on your Mac and configure iPhone to use.

0
Jan 08 '10 at 15:37
source share



All Articles