OpenWrt Forum Archive

Topic: Access to the webinterface via a hostname instead of an IP?

The content of this topic has been archived on 14 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Until recently I have been using a Fritz!Box as a router which has now been replaced by an Asus WL500g premium router running OpenWRT. The router itself is working perfectly. There is only one thing I am wondering about:

From within my LAN I could access the webinterface of my Fritz!Box by using http://fritz.box as the URL in my browser. Knowing the IP address wasn't necessary. Can I do the same with OpenWRT? It would make things more comfortable if I just could type something like http://open.wrt or similar into my browser instead of the IP address itself.

For 8.09 RC1 with LuCI installed this works for me:

root@OpenWrt:~# uci add luci_hosts host
root@OpenWrt:~# uci set luci_hosts.@host[-1].hostname=openwrt
root@OpenWrt:~# uci set luci_hosts.@host[-1].ipaddr=192.168.1.1
root@OpenWrt:~# uci commit luci_hosts
root@OpenWrt:~# /etc/init.d/luci_hosts restart

root@OpenWrt:~# uci set dhcp.@dnsmasq[0].domain=box 
root@OpenWrt:~# uci commit dhcp
root@OpenWrt:~# killall -9 dnsmasq && /etc/init.d/dnsmasq start

And now I can ping the router with openwrt.box.

Yanira wrote:

For 8.09 RC1 with LuCI installed this works for me:

OK, thanks for the info, unfortunately I'm using (and I'm sorry I forgot to mention) Kamikaze 7.09 with X-Wrt, not LuCI. Is there any other way?

X-Wrt -> Network -> Hosts -> Host Names -> IP Address -> 192.168.1.1
X-Wrt -> Network -> Hosts -> Host Names -> Host Name -> open

X-Wrt -> Network -> DHCP -> DHCP Settings -> Domain -> wrt

what is the purpose of setting the hostname in OpenWrt > System > Hostname ?

e.g. UCI: system.@system[0].hostname=openwrt.mydomain.lan

I was hoping that this hostname would be resolved by dnsmasq service running on the same OpenWrt box, but it's not. So the only way to make it resolvable is to add the same name to /etc/hosts or through luci_hosts (as documented above)? (but it feels somehow strange because of doubling the same info in two places)

The discussion might have continued from here.