I haven't tried this specifically with an iPhone, but the principle isn't too hard in general:
- Set up a DNS server
- It needs to be advertised as the DNS server to the iPhone via DHCP
- It needs to by an authoritative server for the zone
.jeff.
and answer responses for wiki.jeff.
- It needs to be able to run recursive queries itself or forward queries to another server if it is not itself a recursive server.
- Set your DHCP server to hand out the IP of your DNS server
- Set your webserver to also respond to the name
wiki.jeff
and select the correct content.
This sounds like a lot, but the pieces are all pretty small and manageable.
The pdns-recursor
package installs the PowerDNS recursor which can be configured (export-etc-hosts=yes
) to also serve up the contents of the /etc/hosts
file -- or any other file following that same format (etc-hosts-file
) on incoming requests. pdns-recursor
is fantastically flexible and fast -- it can be used to paper over weak or flaky ISP-provided DNS systems and this cheapo method of serving a handful of new hostname mappings is really easy. (The full-blown PowerDNS server is something awesome to behold but is extremely overkill for this case.)
When adding a new line to your /etc/hosts
file, recall that 127.0.0.1
means localhost
to every peer -- not this server. Give wiki.jeff
an IP address that your iPhone can route.
You'll have to figure out how to modify your DHCP server to send out a specific IP address for DNS queries. This varies from server to server, but the option is known as option domain-name-servers
in the ISC DHCP server. Add the IP of your newly configured pdns-recursor
system. (Which could be a different machine than the IP address you're serving for wiki.jeff
.)
You'll have to modify your webserver to also handle the wiki.jeff
name; under nginx
this is directive server_name
. Apache needs ServerName
or ServerAlias
directives.