IOS – Adding hosts entry to iOS in absence of DNS

dnshostsiosNetwork

I am working with an application where my iPhone needs to see my laptop on the network under its host name and not the IP address because the SSL certificate works with the name only. At the office, I resolved it by adding a DNS entry mapping my host to my IP and it works. But today I am WFH on my home network which does not have a DNS server capability.

I was wondering if I can somehow edit some hosts file on the iPhone (or some setting or something equivalent) so that the iPhone can see the laptop under its name. They are both on the same network and can reach each other via IP but the network has no DNS.

I also came upon this related material. Here are my pertinent settings:

>hostname
my-mac.local
>scutil --get ComputerName
my-mac
>scutil --get HostName
HostName: not set
>scutil --get LocalHostName
my-mac

Best Answer

You can edit the hosts file on the iOS device if the device is jailbroken.

The hosts file can be found in the same place as on OS X: /etc/hosts. It works exactly the same as the hosts file on OS X.

Set the hostname of your OS X machine using:

sudo scutil --set HostName your-hostname