router by dns (instead of IP)
Posted: Sun May 09, 2010 5:05 pm
Hi,
I wanted to access the router by name instead of IP address so for example 'ping router' will return 192.168.1.1 (so if I change router IP it will be simple to get http and ssh, no need to remember IP address) and in this example 'http://router' will be the interface.
My attempt works now but maybe there is a better way to do this, so if anyone can help that would be great and maybe if you'd like it implement in next firmware version.
I added the line to the file /etc/hosts:
192.168.1.1 router.
now I can 'ping router.' and 'http://router.' (appending a dot to the end of the hostname made it work, the solution is to make sure that we have a domain set in resolv.conf, but I wasn't sure how to do that: [http://www.thekelleys.org.uk/dnsmasq/docs/FAQ])
EDIT: when setting openwrt.lan or same as device name and the domain from the web interface (instead of 'router.') the .lan is auto added so 'ping openwrt' and 'http://openwrt' will work without appending a dot.
Therefore the solution is /etc/hosts:
192.168.1.1 openwrt.lan
Let me know what you think!
I wanted to access the router by name instead of IP address so for example 'ping router' will return 192.168.1.1 (so if I change router IP it will be simple to get http and ssh, no need to remember IP address) and in this example 'http://router' will be the interface.
My attempt works now but maybe there is a better way to do this, so if anyone can help that would be great and maybe if you'd like it implement in next firmware version.
I added the line to the file /etc/hosts:
192.168.1.1 router.
now I can 'ping router.' and 'http://router.' (appending a dot to the end of the hostname made it work, the solution is to make sure that we have a domain set in resolv.conf, but I wasn't sure how to do that: [http://www.thekelleys.org.uk/dnsmasq/docs/FAQ])
EDIT: when setting openwrt.lan or same as device name and the domain from the web interface (instead of 'router.') the .lan is auto added so 'ping openwrt' and 'http://openwrt' will work without appending a dot.
Therefore the solution is /etc/hosts:
192.168.1.1 openwrt.lan
Let me know what you think!