Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've set up a Debian VPN server, to which I connect with my iPhone. It works perfectly, I can browse the web, and see "local" pages.

My question is, if it's possible to "reroute" traffic. Here's an example:

On the iPhone, I go to "www.wiki.jeff" or something, and it reroutes me to "192.168.1.10/wiki/index.php"

That's the general idea I have. Is it possible to achieve this?

share|improve this question

migrated from stackoverflow.com Jul 3 '12 at 20:35

This question came from our site for professional and enthusiast programmers.

    
Are you running a local DNS server such as PowerDNS or BIND? Which one? –  sarnold May 31 '12 at 21:38
    
Yes. Easily doable? Not so much. It would require you running a DNS server, and then setting that as the iPhone's DNS server. Then You would have to have a web server to redirect. –  Corbin May 31 '12 at 21:38
    
@sarnold: I use the standard DNS. I haven't set up any DNS server manually. –  Jeff Huijsmans May 31 '12 at 22:42
    
@Corbin: thanks! So no method which only needs you to connect to the VPN and everything on the iPhone/PC side will be automatically configured? –  Jeff Huijsmans May 31 '12 at 22:42
1  
@JeffHuijsmans Not unless you're willing to hijack some packets (which will be difficult, and a bit shady). –  Corbin May 31 '12 at 22:44

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.