Using hostnames in whole network

Hello!

I am using static static leases for my devices in my network.
Actually I was hoping to be able to ping them afterwards with there hostname instead of ip address. But this doesn’t work.
I was than trying to use the hostname-register. But this also doesn’t work.

What am I doing wrong?

Thanks!

1 Like

GL GUI → System → Advanced Settings → LuCI → Network → DHCP and DNS:

  • Domain required
  • Authoritative
  • Local server: /lan/
  • Local domain: <$myMadeUpDomain>.lan
  • Rebind protection
  • Allow localhost
  • Local service only
  • Non-wildcard

[ Save, Save & Apply ]

LuCI’s password is the same password as GL GUI.

Hi!
Actually my settings were like this except “allow localhost”:

E.g. for one device:
Static Leases:

Ping:

The first ping takes some seconds before error comes. With the second ping the error is raised immediately.

Any other ideas?

The configure should be in host names, not static lease.

Hi!

Thanks for the hint … I did so:

But the result is the same …

BTW … do I than need to specify all my relevant hostnames in “hostname”-Tab? It is not take from static leases when I understand it right

And even when I ping console.gl-inet.com I get the public ip instead of 192.168.0.1

With ping [hostname] the commandline asks the system DNS. As we don’t know your setup, you could test the GL-iNet settings with:
nslookup [host] [server] … For example nslookup console.gl-inet.com 192.168.8.1

Internal in the router:
Even here the internal lookup for the resolve can be different. Look at the file /etc/nsswitch.conf on the router…
hosts: files mdns4_minimal [NOTFOUND=return] dns (taken from my Linux, I have no shell to a router open)
This means if the domain name console.gl-inet.com is listed in /etc/hosts (the file is included in ‘files’), than the entry in ‘mdns4_minimal’ wont be used.

As ‘console.g-inet.com’ is a system hostname, I can imagine it will be overwritten.

Better test with ‘computer’ from your list:
nslookup computer 192.168.8.1

You need to turn off “Rebind protection” to make the local lan IP is not dropped when doing DNS query.

Here some outputs:

All tested with “Rebind protection” disabled
So no difference.

The file /etc/nsswitch.conf doesn’t exist on my router.

I am a little confused about the ‘Server: unknown’.
I know this, when I forgot to setup a reverse lookup zone in AD or Bind. But this should not happen in GL-Inet router with the dnsmasq.

Is 192.168.0.1 the IP of your GL-Inet Router, the one with configured hostname ‘Computer’?

yes, 192.168.0.1 ist the gl-inet router with hostname ‘computer’ configured

LuCI → Network → Diagnostics → IPv4 Ping

PING mypc-win11 (192.168.8.105): 56 data bytes
64 bytes from 192.168.8.105: seq=0 ttl=128 time=1.020 ms
64 bytes from 192.168.8.105: seq=1 ttl=128 time=0.973 ms
64 bytes from 192.168.8.105: seq=2 ttl=128 time=0.909 ms
64 bytes from 192.168.8.105: seq=3 ttl=128 time=0.901 ms
64 bytes from 192.168.8.105: seq=4 ttl=128 time=1.073 ms

--- mypc-win11 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 0.901/0.975/1.073 ms

Certa (GL-AR750), firmware 4.3.7-release4

from router to computer it seems to work

but not the other way around

Note I don’t have Static Leases (DHCP/IP reservation) or Hostnames set within LuCI; the hostname originates fr the device itself. The DHCP range is stock 150 beginning w/ 192.168.8.100 to .249 (GL GUI → Network → Lan). ‘Less is more,’ and all that.

Ping is something different. a ping sends an ICMP packet to the given address. If the address is an IP, it will be routed (via ARP blah blah blah), If it is a host name, it will be resolved first to an IP via DHCP.
The resolving works through UDP port 53 (important for firewall/routing!).
→ That is the reason, why I’d prefer nslookup to analyse DNS issues over ping.

The client got one or more DNS server. A DNS server can be any system that provides a DNS service.

In our case the GL-iNet Router provides a DNS service. Here I’ll test on the Beryl AX, Firmware 4.4.6 Release 2.

My host is named ‘kira’. Out of the box, I can resolve ‘kira’ just from getting a DHCP lease.

lupus@kira:~$ nslookup kira
Server:         192.168.8.1
Address:        192.168.8.1#53

Name:   kira.lan
Address: 192.168.8.168

Now I want another name for this host. So I go to ‘System - Advanced Settings’. Here I open the LuCI UI.
First I’ll check ‘Network - DHCP and DNS’. No changes needed here.
Now I switch to ‘Network - Hostnames’, that is in the same window another tab in your screenshot.
Here I add

  • ‘lupuse’ for 192.168.8.168
  • ‘zoe’ for 192.168.21.10
  • ‘dora’ for 192.168.21.14.
lupus@kira:~$ nslookup lupuse
Server:         192.168.8.1
Address:        192.168.8.1#53

Name:   lupuse.lan
Address: 192.168.8.168

lupus@kira:~$ nslookup dora
Server:         192.168.8.1
Address:        192.168.8.1#53

Name:   dora.lan
Address: 192.168.21.13

lupus@kira:~$ nslookup zoe
Server:         192.168.8.1
Address:        192.168.8.1#53

Name:   zoe.lan
Address: 192.168.21.10

Works as expected.

And now ping:

lupus@kira:~$ ping -c2 lupuse
PING lupuse.lan (192.168.8.168) 56(84) bytes of data.
64 bytes from lupuse.lan (192.168.8.168): icmp_seq=1 ttl=64 time=0.039 ms
64 bytes from lupuse.lan (192.168.8.168): icmp_seq=2 ttl=64 time=0.095 ms

--- lupuse.lan ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.039/0.067/0.095/0.028 ms
lupus@kira:~$ ping -c2 dora
PING dora.lan (192.168.21.13) 56(84) bytes of data.
64 bytes from dora.lan (192.168.21.13): icmp_seq=1 ttl=63 time=7.95 ms
64 bytes from dora.lan (192.168.21.13): icmp_seq=2 ttl=63 time=3.11 ms

--- dora.lan ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 3.109/5.530/7.952/2.421 ms
lupus@kira:~$ ping -c2 zoe
PING zoe.lan (192.168.21.10) 56(84) bytes of data.
From 192.168.21.169 (192.168.21.169) icmp_seq=1 Destination Host Unreachable
From 192.168.21.169 (192.168.21.169) icmp_seq=2 Destination Host Unreachable

--- zoe.lan ping statistics ---
2 packets transmitted, 0 received, +2 errors, 100% packet loss, time 1022ms
pipe 2

The DNS is not interested in the Network. It will stupid resolve all records, even if it does not know anything about the net 192.168.21.0/24.
As you can see this is a transfer network at my home with one host up.

Under Linux I can easily check the DNS server:

lupus@kira:~$ cat /etc/resolv.conf
search lan
nameserver 192.168.8.1

Under windows, it is somewhere in ‘ipconfig /all’ … If you have set and changed a lot on your windows, you may need a ipconfig /flushdns to start over. See ipconfig

Please make sure there is no personal firewall/security solution/vpn client active, that is messing with your DNS settings ‘for security’.

Hi!
my ipconfig /all gives me:

I also did ipconfig /flushdns
the “lan”-entry at the first line I just added … but it doesn’t make any difference

but the result of nslookup is still:

Doing it from another devices (linux) shows:
image

at least this devices knows the server … but computer isn’t found

this is maybe also of interest:

when I do this from the router itself I get

Obviously he knows the right IP but how can I interpret “Can’t find computer: No answer”??

But you don’t have AdGuardHome active? This would mess with your DNS on the router.

So lets try to switch to the router: ssh root@192.169.8.1.

root@GL-MT3000:~# netstat -tulpen | grep :53 should show something like:

tcp        0      0 127.0.0.1:53            0.0.0.0:*               LISTEN      22125/dnsmasq
tcp        0      0 192.168.xxx.xxx:53       0.0.0.0:*               LISTEN      22125/dnsmasq
tcp        0      0 192.168.9.1:53          0.0.0.0:*               LISTEN      22125/dnsmasq
tcp        0      0 192.168.8.1:53          0.0.0.0:*               LISTEN      22125/dnsmasq
tcp        0      0 ::1:53                  :::*                    LISTEN      22125/dnsmasq
tcp        0      0 fe80::20f1:5aff:xxxx:xxxx:53 :::*                    LISTEN      22125/dnsmasq

vim /etc/dnsmasq.conf unfortunately is complete commented.
so i go with the sledge hammer grep dora /etc/* -r and got /etc/config/dhcp: option name 'dora'

here are all my configurations:

config domain                
        option name 'console.gl-inet.com'  
        option ip '::ffff:192.168.8.1'                         
                                                     
config domain                  
        option name 'dora'          
        option ip '192.168.21.14'   
                                         
config domain                  
        option name 'lupuse'  
        option ip '192.168.8.168'

Please check with cat /etc/resolv.conf if nameserver 127.0.0.1 is set (cat /tmp/resolv.conf should be the same, in fact is /etc/resolve.conf a symlink to /tmp/resolv.conf in a normal OpenWrt Setup).
Than check with netstat -tulpen |grep 53 if the listening service on port 53 is dnsmasq.
Make sure at the GUI (admin Panel), that AdGuardHome and similar services are disabled.

At last step for this part, you could check if the configuration is written in /etc/config/dhcp

OK … found out what is happening …

When disabling the OpnVPN client it is working:

C:\Users\diete>nslookup computer
Server:  console.gl-inet.com
Address:  192.168.0.1

Name:    computer.lan
Address:  192.168.0.10

So how can I combine openvpn client with DNS to work??

In the whole thread, you never mentioned OpenVPN. You are talking about DNS in your ‘network’.

Where did you disabled OpenVPN?
Client (Computer) or Router?
Where do you want resolve your hostnames?

This is a little more complex.

  • You need to make the dnsmasq available in your VPN. Or at least accessible.
  • You need a route, to make sure the devices can reach the DNS Server (to resolve the names) and a route to make sure the clients can access the resolved IPs.

Well, I didn’t realize that OpenVPN will have an impact on DNS … that is why I didn’t mention it …
I disabled OpenVPN client on my gl.inet-Router
Hostnames shall be resolved on the Router

Client is configured like this:

Can you give me more hints on how to configure dnsmasq for VPN and how to make the right route??

Thanks!!