How can I give a custom URL name for a router IP?

2

I have a router I'm playing with and I am curious if it is possible for me to give a custom URL name to the IP of the router, so that people in my house can type http://www.my-fancy-url.com rather than http://aaa.bbb.ccc.ddd—not only on PCs but also on mobile devices.

I heard that I could do this if I make my own DNS server and somehow either set it to be the default while connected to my router, or tell the people to configure DNS manually (which is still better than forcing people to type 123.456.789 every single time they want to visit).

I tried reading up on how DNS protocol works to try to implement it in Node or Java but the protocol seems too hard for me to wrap my head around.

I also heard OpenDNS is an option, but I want to avoid it.

Are there any simpler options for creating a simple DNS server that can process one specific request before passing it to 8.8.8.8 (or nowhere, since this router is not actually connected to the internet).

Dmitry

Posted 2016-06-25T18:54:43.617

Reputation: 121

Do you have a pc/server on your network that is always powered on? and if so what OS is it? – m3z – 2016-06-25T19:19:57.843

Yes but I'm not sure how that is related to the question. To have my website up, I must have a computer running (since it is hosted on a localhost). – Dmitry – 2016-06-25T19:21:41.337

you need a pc running on your network upon which to host a dns server such that other hosts connecting to your network can query it. If you configure a dns server on your network and then it is not available it may be as if your internet connection was down. – m3z – 2016-06-25T19:24:23.070

@m3z I want to run a DNS server on the same computer that has the website, just bound to a different address/port. – Dmitry – 2016-06-25T19:25:23.247

If it's to be running on the same computer always you might want to investigate the hosts file. On linux that would be /etc/hosts and on windows that is C:\Windows\System32\Drivers\etc\hosts – m3z – 2016-06-25T19:25:54.733

@m3z I want to be able to access it from a mobile device or another computer in my home connected to my router. Not all of those devices have host files. – Dmitry – 2016-06-25T19:26:31.770

Let us continue this discussion in chat.

– m3z – 2016-06-25T19:26:45.567

Answers

1

I personally use powerDNS to do similar things to this on my own network.

It runs on a linux (debian) based pc that is on all the time and servers as my local network's dns server as well as other functions (e.g. file server). Then on my router I configured a firewall rule that allowed outgoing dns traffic from my dns server pc but redirect all other outgoing dns traffic to my dns server pc.

The powerdns instance I have installed will then forward any queries which it doesn't have an authoritative record for. This allows me to make up domain names or override public dns settings and point them to hosts within my own network.

I believe a similar setup is also possible if you have a windows server on your network.


Assuming that your router's ip address is in a private IP range (see https://en.wikipedia.org/wiki/Private_network) and you own a public domain name, an alternative solution would be to set up a subdomain and have the A record point to your router ip.

e.g. router.mydomain.com with an A record pointing to 123.456.789.1

This would have the effect that any host with correctly configured dns which was connected to your network would be directed to the router when they entered router.mydomain.com while if they were outside your network they would probably not see anything or perhaps they would see their own router.

m3z

Posted 2016-06-25T18:54:43.617

Reputation: 347

1

If you’re going to run a DNS service, you might as well move the DHCP service away from the router, too. That way, no manual client-side configuration is required.

I recommend using Dnsmasq, an all-in-one solution for SOHO networks. It provides both DHCP and DNS services and is very easy to set up. It requires very little resources, so you could run it on a Raspberry Pi or your router (with a firmware replacement like OpenWrt).

Dnsmasq requires either Linux, *BSD or OS X, though.

The (additional) configuration options you need would look somewhat likes this:

# Set DHCP range:
dhcp-range=lan,192.168.2.100,192.168.2.199,255.255.255.0,24h
# Set router IP:
dhcp-option=lan,3,192.168.2.1
# Set upstream DNS:
server=8.8.8.8
server=8.8.4.4
# Don't load DNS from /etc/resolv.conf
no-resolv
# Create router DNS name:
address=/my-router.example.com/192.168.2.1

Daniel B

Posted 2016-06-25T18:54:43.617

Reputation: 40 502

1

If you have a network and want those connected to the network to autoconfigure, you probably want to set up a DHCP, which assigns IP addresses to the clients. In addition to simply assigning IP addresses, the DHCP protocol can also transfer information about which DNS servers to use.

So you probably have computer X in your network that has your website. On that computer you would then also have running DHCP and also DNS. Since all of them use different ports, this is no problem. Have the DHCP return (in addition to the IP address leases) also the Nameserver IP of computer X. Have the DNS server return the router’s IP when it’s name is queried, and forward all other IPs to the name servers you get from your provider.

Ro-ee

Posted 2016-06-25T18:54:43.617

Reputation: 1 212