I have an OpenWRT router acting as an Wifi access point to a local network. No actual routing currently involved.
The ip adress of the wlan0
interface on the router is statically set to 192.168.120.1
. Dnsmasq is running as a service there providing DHCP and DNS.
My goal is to allow the router's web interface to be reachable to all computers in the network as http://router.net
instead of having to type 192.168.120.1
.
LuCI
, openWRT's web interface seems to allow multiple options to achieve this.
1 Network -> DHCP & DNS -> Static Leases
My initial idea was that this is for static leases for DHCP, but the deacription suggest it might also allow setting host names.
Static leases are used to assign fixed IP addresses and symbolic hostnames to DHCP clients.
I have entered both the MAC and the IP address of wlan0
on the router and the desired hostname, but this didn't result in being able to ping router_static_lease
from a laptop in a subnet.
2 Network -> DHCP & DNS -> Resolv and Hosts Files -> Additional Hosts files
The second assumption was to add a line to /etc/hosts
on the router and it will, because of dnsmasq, distribute this mapping to all the computers in the subnet.
That also didn't give the expected result.
2 Network -> Hostnames
The third approach was to add an entry to the above form. Again, no success
After setting all of those I restart the router and try pinging them from a computer in the subnet.
~$ ping router_static_lease
ping: router_static_lease: Name or service not known
~$ ping router_hostnames
ping: router_hostnames: Name or service not known
~$ ping router_etc_hosts
ping: router_etc_hosts: Name or service not known
Running dig
for those commands provides little help for it points to the systemd resolver.
~$ dig router_etc_hosts
; <<>> DiG 9.10.3-P4-Ubuntu <<>> router_etc_hosts
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 22668
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;router_etc_hosts. IN A
;; Query time: 841 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Tue Jun 20 15:27:14 CEST 2017
;; MSG SIZE rcvd: 45
Running ~$ systemd-resolve --status
however shows that it is trying to resolve with the correct server 192.168.120.1
.
~$ systemd-resolve --status
Link 3 (wlp4s0)
Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 192.168.120.1
DNS Domain: lan
My question is what am I doing wrong and what would be the proper way to achieve this?
If you know how to do it in the command line, ignoring the web interface, that will also be helpful.
Best Answer
I have exact the same configuration on my lab and it works well In this case you are using DNS mask and not bind servers so you only have alias not records. For you can dig the hostnames your router has to be on your guests dns resolution as dns server.