Do you have any router which supports DD-WRT Firmware? My congratulations, you can create own domain name in your local network and you can assign that to any IP-address in your local network. You will be able even to assign your IPs with ports to a domain name. Your daily tries to have access by IP to a device will sink into oblivion.
Okay, enough words, just let’s do it.
What do you need to check?
- Your version of DD-WRT does support access to the page Services=>Services and there you have Sections:
- Services Management
- DHCP Server
- Additional Dnsmasq Options
- You have Network Address Server Settings (DHCP) on the page Setup as well.
We have already checked and all settings are available.
First of all, we are going to change Setup => Basic Setup => Network Setup => Network Address Server Settings (DHCP). Make enable DHCP Server and fill out your fields by Static DNS 1 and Static DNS 2. You can use DNS like by me there are public DNS of Nord VPN or whatever you want.
Make please tick by Use DNSMasq for DNS and DHCP-Authoritative.
Client Lease Expiration will be by default 1440 min. Apply and save changes.
After that, we need to go to Services=>Services.
On this page change the Used Domain from WAN to LAN&WLAN if it hasn’t done earlier. By Lan Domain write whatever you want, it will be our first level domain name like .com, .org and e.g.
Before we will do the next step, we have to figure out the mac addresses our devices and their IP-addresses, which should have own domain name in the intranet.
These we will type into the Static Leases.
Self-explanatory, we will type in Mac into MAC Addresses, IP-address into IP Address but what should we need to know is a Hostname and Client Lease Expiration, the last one will have 1440 by default, but the hostname can have whatever you want, it will be our second-level domain name in our local network, like that google.com but in my case, there are wrt.home and jenkins.home.
Be sure, that you have enabled Dnsmasq and write this line
into Additional Dnsmasq Options, where home is your “LAN Domain” from “DHCP Server”. Apply and save changes.
It’s all for simple cases if you want to have just an own domain name for a device in your local network. But what if you need a redirection to a specific port?
In this case, we have to do an extra step. We are going to the page Administration => Commands and we have to write a command
iptables -t nat -A PREROUTING -p tcp -i br0 -d jenkins --dport 80 -j DNAT --to 192.168.178.20:8080
where jenkins and 192.168.178.20 are your domain name and the IP address from the Static Leases and 8080 is your port what you need to have.
Save the changes and run the command.
In the end
In the end, your settings should look like bellow.
Now, you can reach your device by domain name in your local network.???