What's new
  • 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!

Change hostname

erik.simonson

New Around Here
Hi,

This may be a frequent question but I have googled quite a bit without suceess.

How can I change the default hostname of the Asus running Merlin? I.e. what I want to achieve is that the default hostname and domain should be for instance gateway.merlin.com. If I were to choose this I want the server when running a nslookup on a client to come back with the following first two rows:

Server: gateway.merlin.com
Address: 192.168.0.1

(My current two first rows read:
Server: router.asus.com
Address: 192.168.0.1)

I have played around with additional hosts.add and hosts.con file as well as dnsmasq.add and dnsmasq.conf without success on my particular question.

I would appreciate any input on this question.

Regards,
Erik
 
router.asus.com is automatically generated into /etc/hosts by the firmware. You should be able to modify it either by fully replacing it with a /jffs/configs/hosts.conf or modify that line with a /jffs/scripts/hosts.postconf

I'd be a little bit careful about changing the router hostname however....I'm not sure, but there may be other places in the firmware that depend on this hostname.
 
Thanks for your reply John!
You are at least confirming that I am on the right track. I also note your caution on changing the hostname.
 
How can I change the default hostname of the Asus running Merlin? I.e. what I want to achieve is that the default hostname and domain should be for instance gateway.merlin.com. If I were to choose this I want the server when running a nslookup on a client to come back with the following first two rows:

Server: gateway.merlin.com
Address: 192.168.0.1
Is there any particular reason for doing this other than cosmetic reasons?

Technically, the server name you are seeing is not the host name, it is an alias (of the LAN interface). The real host name is set in the GUI at LAN > LAN IP > Device Name.

For example, my host name is RT-N66U. You can verify it in the GUI, by looking at the routers command prompt and by using "uname -n".
Code:
admin@RT-N66U:/# uname -n
RT-N66U
If you look at /tmp/etc/hosts you can see the host name together with its aliases.
Code:
admin@RT-N66U:/# cat /tmp/etc/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-N66U. RT-N66U
192.168.1.1 asusrouter. asusrouter
When you do your nslookup it uses the first name in the hosts file that matches the IP address. By default that will be "router.asus.com". If you insert a new entry before that line it will use that name instead. So,
Code:
127.0.0.1 localhost.localdomain localhost
192.168.1.1 gateway.merlin.com
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-N66U. RT-N66U
192.168.1.1 asusrouter. asusrouter
 
Last edited:
Thanks ColinTaylor!

Your elaborative answer is appreciated. So I created the /jffs/configs/hosts.conf file with the following content:

***
127.0.0.1 localhost.localdomain localhost
192.168.1.1 gateway.merlin.com
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-N66U. RT-N66U
192.168.1.1 asusrouter. asusroute
***

As far as I understand it should completely replace the original hosts-file generated.

However, when doing 'cat /etc/hosts' (after reboot) it results in
***
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-N66U. RT-N66U
192.168.1.1 asusrouter. asusroute
***

So the /jffs/configs/hosts.conf file does not seem to be loaded properly. I have actually added a /jffs/configs/hosts.add file instead. That one is read ok, with the following entry in the log:
Dec 30 21:09:21 custom config: Appending content of /jffs/configs/hosts.add.

However, when doing the aforementioned /jffs/configs/hosts.conf there is no mention of that file being loaded in the log. So is it not possible to replace the dynamically generated /etc/hosts with one in /jffs/configs/hosts.conf? has anyone succeded?
Likely it is me doing something wrong......
 
I'll just point out that in your original post your routers IP address was 192.168.0.1 whereas mine is 192.168.1.1. Make sure your hosts file contains the correct address.
 
Last edited:
You might want to try something like this:

/jffs/scripts/hosts.postconf

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

pc_insert "localhost" "192.168.0.1 gateway.merlin.com" $CONFIG

UPDATE: See post here.
 
Last edited:
You might want to try something like this:

/jffs/scripts/hosts.postconf

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

pc_insert "localhost" "192.168.0.1 gateway.merlin.com" $CONFIG

Thank you very much ColinTaylor! This proved to be the solution! I sincerely appreciate your help! Thanks!

And yes....I had a typo in the post above on IP-addresses (192.168.1 instead of 192.168.0). However, my attempt on the router was correct....but that is now of less importance since the problem is solved!

Once again, thanks!
 
Is there any particular reason for doing this other than cosmetic reasons?

Technically, the server name you are seeing is not the host name, it is an alias (of the LAN interface). The real host name is set in the GUI at LAN > LAN IP > Device Name.

For example, my host name is RT-N66U. You can verify it in the GUI, by looking at the routers command prompt and by using "uname -n".
Code:
admin@RT-N66U:/# uname -n
RT-N66U

So my RT-AC66U doesn't have a GUI 'Device Name' field, under the GUI of LAN>LAN IP> I have only two options: IP Address (set to 192.168.0.1) and subnet mask. No field for hostname.
uname -n does produce the same RT-AC66U its set to at present. How this may well be the difference between the AC and the N model, but that seems very odd if thats the case. I'm on the latest firmware.

The reason I want to change the hostname is I don't want to have to type the long IP address in a web browser to use the management interface, but that is all that works. I have 'wifi' in my PCs host table, so it translates that to 192.168.0.1 and I get the login screen - but then when entering credentials it just reloads the same login screen over and over. So I'm trying to figure out where ASUS got too cute and is borking it all up. My older linkssys router had no such problem, but this one's web interface.

So there isn't a hostname executable (joy) so maybe changing the hostname is just not possible on the AC66U. <frown>
 
Well, I'll correct my stupid self... <embarassing> ... the issue was I wasn't using the Asuswrt-merlin firmware (DOH!). Stupid me. Flashed the firmware and NOW I see a hostname field.
Now I'm on 380.69_2.

But it was all for naught, because despite having changed the hostname to 'wifi' (and it reports 'wifi' when asking via uname -n). I still cannot connect via Firefox using the address 'wifi/' in the address bar.
That is, I cann connect but ONLY to the login screen 'http://wifi/Main_Login.asp'. Once I enter my credentials there, it takes them and promptly reloads the login screen again. Damit.

running 'nslookup wifi' does come back with the right IP address of 192.168.0.1
 
Work OK here, but I'm on a different version of the firmware.

Try clearing the browser cache. Try another browser from a different machine.
 
Firefox and IE11, no joy. So on your system you can log in with a hostname only as the URL in the browser? Must just be a defect on the RT-AC66U, which still displays 'RT-AC66U' on the login screen (even though the hostname is reported as 'wifi') if that is a clue (though I expect the model number is hardcoded in the HTML presented.

I'm thinking they got too cute with the gui in some way. Just cleared everything in IE 11, restarted it. The login button calls login.cgi .. and that just reloads the same damn login page. Argh.
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

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