What's new

Giving router a unique name for remote syslog server?

  • 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!

maxbraketorque

Very Senior Member
I'm setting up a remote syslog server, and I'd like to give my routers unique names so that they distinguishable in the syslog. Currently, my AC86U shows up in the syslog as "router.asus.com". I'd like to change the name, but I don't see any means in the GUI settings. Did I miss it, or is there some other way to change it?
 
@arthurlien, another issue I'm seeing is that the router is assigning a log level of "emergency" (7) to roaming assist entries. Seems that "informational" would be much more appropriate.
 
Did I miss it, or is there some other way to change it?
I don't think the name is controlled by syslogd as such. The remote syslog server is just doing a reverse DNS lookup on the source IP address. Because 192.168.1.1 (or whatever your router uses) is hard-coded as the first entry in the router's hosts file it will always resolve to that.
Code:
# nslookup 192.168.1.1
Server:         192.168.1.1
Address:        192.168.1.1#53

1.1.168.192.in-addr.arpa        name = router.asus.com.
Code:
# cd /etc
# cat hosts
127.0.0.1 localhost.localdomain localhost
192.168.1.1 router.asus.com
192.168.1.1 www.asusnetwork.net
192.168.1.1 www.asusrouter.com
192.168.1.1 RT-AC68U.home.lan RT-AC68U
192.168.1.1 asusrouter.home.lan asusrouter
You could fix it on the remote syslog server by putting an entry in its hosts file, but that's pretty ugly.
 
Anyway -- one can always look at this thread - OMG, the power of search!
:D You don't expect me to remember a solution I posted nearly three years ago. :D

Also, who says I never update my code :p? Here's the new improved version 2 :D:

/jffs/scripts/hosts.postconf
Code:
#!/bin/sh
CONFIG=$1
source /usr/sbin/helper.sh

addr="$(nvram get lan_ipaddr)"
name="$(nvram get computer_name)"
domain="$(nvram get lan_domain)"
pc_insert "localhost" "${addr} ${name}.${domain} ${name}" $CONFIG
Code:
# nslookup 192.168.1.1
Server:         192.168.1.1
Address:        192.168.1.1#53

1.1.168.192.in-addr.arpa        name = RT-AC68U.home.lan.
 
Last edited:
I appreciate the help. I did actually search, but I wasn't aware that this was a host name thing, so I didn't think to search on that.

Team effort - as long as it helps with the problem...

Community is always here to collaborate...
 
a solution I posted

will changing the hostname from router.asus.com to whatever
harm how other apps people add to merlin (after a hard reboot)?
i'm using diversion (small) and spynet. i am wired + 3x2 ssids.

also, i don't understand how to follow your post.
do i create a text file called hosts.postconf
containing the text you posted in pink and
deposit it in the /jffs/scripts/ location where
dnsmasq.postconf (from merlin) is now ?

there are 2 pink areas, so what file is the second one called?
or are both 2 pink areas sections of the same one hosts file.

how would i change your script to give the value whatever
just one word, not = name.domain.url
or does asus/merlin somehow insist on using that template?
sorry to ask, it's just when i used dd.wrt there was a field
in the gui i just filled in whatever i wanted and that was it.
 
Last edited:
will changing the hostname from router.asus.com to whatever
harm how other apps people add to merlin (after a hard reboot)?
i'm using diversion (small) and spynet. i am wired + 3x2 ssids.
I can't think of a reason why it would cause a problem but anything is possible. I'm been running it for a couple of months and haven't had any problems. Anything that uses router.asus.com should be unaffected.

Just to be clear, you are not changing the host name of the router. The only thing you are changing is the host name returned from doing a reverse DNS lookup on the IP address. All the existing forward lookups remain the same. So router.asus.com, www.asusnetwork.net, www.asusrouter.com, asusrouter and RT-AC68U all return exactly the same address as before.
Code:
C:\>nslookup router.asus.com
Server:  RT-AC68U.home.lan
Address:  192.168.1.1

Name:    router.asus.com
Address:  192.168.1.1


C:\>nslookup asusrouter
Server:  RT-AC68U.home.lan
Address:  192.168.1.1

Name:    asusrouter.home.lan
Address:  192.168.1.1


C:\>nslookup www.asusrouter.com
Server:  RT-AC68U.home.lan
Address:  192.168.1.1

Name:    www.asusrouter.com
Address:  192.168.1.1


C:\>nslookup RT-AC68U
Server:  RT-AC68U.home.lan
Address:  192.168.1.1

Name:    RT-AC68U.home.lan
Address:  192.168.1.1


C:\>nslookup 192.168.1.1
Server:  RT-AC68U.home.lan
Address:  192.168.1.1

Name:    RT-AC68U.home.lan
Address:  192.168.1.1
 
also, i don't understand how to follow your post.
do i create a text file called hosts.postconf
containing the text you posted in pink and
deposit it in the /jffs/scripts/ location where
dnsmasq.postconf (from merlin) is now ?.
Yes that is correct. Remember to make the script executable in the same way as any other postconf script.

there are 2 pink areas, so what file is the second one called?
or are both 2 pink areas sections of the same one hosts file.
The second pink block in post #6 is just an example of me typing in an nslookup command to demonstrate that the script is working.

how would i change your script to give the value whatever
just one word, not = name.domain.url
or does asus/merlin somehow insist on using that template?
sorry to ask, it's just when i used dd.wrt there was a field
in the gui i just filled in whatever i wanted and that was it.
I think you might be talking about something different than what this thread is about. You can set the hostname and an optional domain name through the router's normal admin interface. You don't need a script for that.
 
Yes that is correct. Remember to make the script executable in the same way as any other postconf script.

ok, so you went with the example;
RT-AC68U.home.lan (your lan's 192.168.1.1)
so how exactly did you plug those values into;
pc_insert "localhost" "${addr} ${name}.${domain} ${name}" $CONFIG
o_O
 
ok, so you went with the example;
RT-AC68U.home.lan (your lan's 192.168.1.1)
so how exactly did you plug those values into;
pc_insert "localhost" "${addr} ${name}.${domain} ${name}" $CONFIG
o_O
The 3 lines preceding the one you quoted gets the IP address, host name and domain name from the router's NVRAM. So you just use that script "as is" without modification. Then whatever you have set for those 3 values in the router's GUI will be picked up.
 
whatever you have set for those 3 values in the router's GUI will be picked up.

where are these 3 values?
under wan all i see is
host name = local

under lan
device name = whatever
and this value is ignored by reverse dns
i still only get router.asus.com

under lan dhcp
domain name = local
 
under lan
device name = whatever
and this value is ignored by reverse dns
i still only get router.asus.com
Then the script hasn't worked properly. Check for errors in the syslog. Confirm the changes (after rebooting of course) by looking at the router's hosts file.

under lan dhcp
domain name = local
Using "local" as a domain name is a poor choice because that is used by Avahi.
 
LAN > LAN IP > Device Name
LAN > LAN IP > IP Address
LAN > DHCP Server > Domain Name

thanks colin for holding my hand thru this ;)

now i see what your script is doing... by taking the gui variables that had been ignored
and actually using them to replace that router.asus.com default value.
after a reboot (of both my router and ont|modem) my reverse dns lookup "hostname"
now shows the device.domain i want it to display to the world :D

FYI: i noticed this may not work perfectly using merlin 384.7
so make sure you get 384.7_2 and beyond for the full benefit.
 
Last edited:
Apologies for kicking an old topic, but how can I get a clean hostname on my remote syslog server (Pi running rsyslog)?

Code:
> nvram get lan_hostname
ac86u

And that's the hostname I would like to see, but this is (similar to) what I get with Asuswrt-Merlin 386.1 on the syslog server:

Code:
ac86u-12A3445-Z
 
Last edited:
@XIII The hack in post #6 has not been needed for some time as it has been fixed in the firmware. (So remove that hosts.postconf file if you created one otherwise you'll pick up the Samba name.)

What do you have set for your router's host name in LAN - LAN IP? Do you have a domain name set?

What do you have set for the Device name in USB Application - Network Place (Samba) Share / Cloud Disk ?
 
Last edited:
  • hostname: ac86u
  • domain: home.lan
  • device name: not configured (default value seems AC86U?)
(I did not use that postconf file)
 

Latest threads

Sign Up For SNBForums Daily Digest

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