Can a router map a URL to a local ip?

9

3

I'm setting up a facility with many different computers where I don't have access to their hosts files. How would I map test.com to a local server without using the hosts file? Can this be done using a simple home router?

I'd like to be able to tell guests: "If you're on our wifi, you can just go to test.com to view our local website."

I'd prefer to keep answers hardware-agnostic, but if it helps, I'm using a D-link DIR-655.

I'm aware of this answer, but I don't think it addresses these issues directly: How can I map a domain name to an IP address and port? (Am I mistaken?)

Thanks!

Sauce McBoss

Posted 2012-03-18T20:54:31.657

Reputation: 855

Answers

7

I haven't found a home router that can run this without using some custom firmware. However, I use the same server running the sites to host a DNS server internally at home. All the machines point to the DNS server where I have a set of custom directs set up, and all other queries are sent to my ISP's DNS server to resolve correctly. I use DHCP to assign IP's and DNS server addresses to all the clients.

BinaryMisfit

Posted 2012-03-18T20:54:31.657

Reputation: 19 955

Thanks -- that confirms my findings. Is this particularly difficult to set up? (I'm running Ubuntu server) – Sauce McBoss – 2012-03-18T21:43:54.543

There are a bunch of lightweight, simple DNS server softwares out in the world. So, setting up a DNS server can be hard or it can be easy. – djangofan – 2012-03-18T21:49:46.530

@lrog If your using Ubuntu Server then look at DNSMasq. It's a DHCP/DNS server roled into one and I have used it successfully in the past, however spent a lot of time searching for the correct config.

– BinaryMisfit – 2012-03-19T07:28:57.583

3

I would just register the domain for real and point it to a local IP address. For example, if you registered example.com and your local IP address range was 192.168.1.0/24, you could point www.example.com to 192.168.1.184 and run your web server on that IP address. While the name would resolve outside of your network, it wouldn't actually go anywhere.

If you don't want to register a domain for real, instead you can just use your own name servers that make that name resolve however you want. However, I don't recommend this because it could conflict with a real domain.

If you really want to do it by router, use a router than can support Dnsmasq. Any router that can support DD-WRT will do.

David Schwartz

Posted 2012-03-18T20:54:31.657

Reputation: 58 310