What's new

Make router aware of LAN hostnames

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

gds

Occasional Visitor
With dhcp setup on the rt-ac56u with lastest merlin firmware, I am able to ping any host on the LAN from any other host. However, if I ssh or telnet into the router and attempt to ping those same hosts, it prints "bad address", even with the full domain name. (Ping of WAN sites work OK from the ssh command line, e.g., ping yahoo.com.) Is there a way to make the router aware of host names on the LAN too?
 
I was looking into this earlier and I think one point is that the router has two different resolv.conf.

There is one /etc/resolv.conf and one /tmp/resolv.conf.

Check what they contain.
 
I was looking into this earlier and I think one point is that the router has two different resolv.conf.

There is one /etc/resolv.conf and one /tmp/resolv.conf.

Check what they contain.

I think you really mean files

Code:
/etc/hosts
/etc/hosts.dnsmasq

as resolv.conf contains DNS nameserver references such as GOOGLE or OPENDNS.

a hack is to issue:

Code:
cat /etc/hosts.dnsmasq >>/etc/hosts

but if you just want to add a single host (say to access an ADSL modem in bridge mode like I used to)

then create the

Code:
hosts.add

file with the appropriate entries.

P.S. There is only one resolv.conf file, the etc one is a symbolic link (alias) to the physical file.


/etc/resolv.conf->/tmp/resolv.conf

Regards,
 
Last edited:
resolv.conf is used by the local machine to tell how to resolv names. When running commands on the router the name server pointed out in resolv.conf is used. If the local machine is running a name server resolv.conf should point to localhost.

On my router I have two, but it might be that I create one of them myself.

/etc/resolv.conf lists 127.0.0.1
/tmp/resolv.conf (which is referred to from dnsmasq.conf) lists google name servers


The reason that it works on computers on the LAN but not the router most likely is that the computers on the LAN use the name server they get by DHCP (which is the routers address, thus they ask dnsmasq). But the router itself uses /etc/resolv.conf and if it points to external name servers rather than localhost you get the situation described.


It seems as if you misread the question?
 
Last edited:
resolv.conf is used by the local machine to tell how to resolv names. When running commands on the router the name server pointed out in resolv.conf is used. If the local machine is running a name server resolv.conf should point to localhost.

On my router I have two, but it might be that I create one of them myself.

/etc/resolv.conf lists 127.0.0.1
/tmp/resolv.conf (which is referred to from dnsmasq.conf) lists google name servers


The reason that it works on computers on the LAN but not the router most likely is that the computers on the LAN use the name server they get by DHCP (which is the routers address, thus they ask dnsmasq). But the router itself uses /etc/resolv.conf and if it points to external name servers rather than localhost you get the situation described.


It seems as if you misread the question?

No I read the OP and given my current comprehension skills correctly answered the question to address the issue of being able to reference devices on the local LAN by name on the Router.

However if manually creating the file

Code:
/etc/resolv.conf

with the entry 127.0.0.1 is the 'more technically' correct solution (in lieu of say a Dnsmasq tweak etc.), then I bow to your more considerable technical knowledge despite you being unsure if you did indeed create the /etc/resolv.conf file or not! ;)

Regards,
 
Then you are not reading what I am reading:

I am able to ping any host on the LAN from any other host.
This means DNS lookups from any computer on the LAN can find LAN hostnames.

This means that the hostnames ARE already configured in dnsmasq, otherwise how would the lookups possiblt work? By mind reading?

However, if I ssh or telnet into the router and attempt to ping those same hosts, it prints "bad address", even with the full domain name.

This means DNS lookups from the router itself does not find LAN hostnames.

(Ping of WAN sites work OK from the ssh command line, e.g., ping yahoo.com.)

This means the DNS lookups from the router itself works, but are using an external names server instead of the routers dnsmasq.


As long as resolv.conf points to external names servers it does not matter how much you configure dnsmasq; it won't be used for DNS lookups.
 
Last edited:
Then you are not reading what I am reading:


This means DNS lookups from any computer on the LAN can find LAN hostnames.

This means that the hostnames ARE already configured in dnsmasq, otherwise how would the lookups possiblt work? By mind reading?



This means DNS lookups from the router itself does not find LAN hostnames.



This means the DNS lookups from the router itself works, but are using an external names server instead of the routers dnsmasq.


As long as resolv.conf points to external names servers it does not matter how much you configure dnsmasq; it won't be used for DNS lookups.

So if I issue

Code:
ping router.asus.com

on the router or any client that is connected to the router, is it correct that the name resolution is performed by looking in

/etc/hosts

first?

So the hosts file will always be used before attempting to use /tmp/resolv.conf, consequently RMerlin provides access to hosts.add (or now using post-config scripts) but doesn't appear to expose resolv.conf to the same modification.

So I stand by my original suggestion that having appropriate entries (appended/cloned from hosts.dnsmasq) in /etc/hosts will solve the original problem.

Regards,
 
After posting my question, I did manually add a LAN host to the router's /etc/hosts file and I could ping from the router using the name entered therein. So I can see that appending the /etc/hosts.dnsmasq contents to /etc/host would also work.

I also tried adding "nameserver 128.0.0.1" to the top of /etc/resolv.conf and it also fixed the problem. (On my system, /tmp/resolv.conf is the same file symbolically linked to /etc/resolv.conf and not separate files.)

But, I doubt if these changes will survive a reboot of the router (haven't tried rebooting). They appear to reside on the tmp filesystem in RAM, not in nvram or jffs flash. Is there way to make these changes permanent?

Thanks,
-gds
 
Put a script in /jffs/scripts which does the

cat /etc/hosts.dnsmasq >>/etc/hosts

This should get run at startup, I think. Its how I add my custom dnsmasq option.

Which brings me on to my own problem, which I posted but no reply so I'll ask here. When I configure clients to explicitly use, rather transparently; privoxy which I have running on the router my custom dnsmasq options get overridden. Will this same script file Likely fix this? cat /etc/hosts.dnsmasq >>/etc/hosts

"server=/google.com/216.239.32.20
server=/google.co.uk/216.239.32.20"
 
Thanks, made script /jffs/scripts/host.postconf

Code:
#!/bin/sh
# Append configure hostnames to host file so
# router aware of at least these hosts.
#
cat /etc/hosts.dnsmasq >> /etc/hosts
 
Last edited:

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top