Web interface access via interface name not hardcoded ip address

How to access LUCI via hostname without hard coded IP address. IP address is obtained from DHCP of DNSmasq.

Dnsmasq DHCP will provide IP address to LAN interface.
Lets say 192.168.1.1 to lan interface, "lan" which is the interface name see in /etc/config/network.

This address can be changed to 10.0.0.1 when there is a conflict with WAN interface.
Hence, what methods are available to use interface name?

dnsmasq.conf option to point to interface name like "lan" instead of physical address.

I don't want to have hard coded IP address as below:
config dnsmasq
...
list address '/router.domain.com/192.168.1.1'

Example:
config interface 'lan' <<<<<<<<<<< WANT TO USE NAME
option force_link '1'
option type 'bridge'
option proto 'static'
option ipaddr '192.168.1.1' <<< DONT WANT HARDCODED IP ADDRESS
option netmask '255.255.255.0'

I am not clear on your terminology. Are you referring DNSmasq to provide DHCP client functionality?
In OpenWRT:
DNSmasq provides DHCP server functionality.
The DHCP client by default are via: udhcpc for v4 and odhcp6c for v6.
I can get the IP address via
ifconfig lan | grep 'inet addr' | sed -e 's/:/ /' | awk '{print $3}'
But in the config file, cannot have any variables to assign the above.
dnsmasq.conf will be like this:

local_variable_ip=ifconfig br-lan | grep 'inet addr' | sed -e 's/:/ /' | awk '{print $3}'
address=/.myrouterlogin.com/$local_variable_ip <<<< Will not work

Any idea how to get the above working?

In a default installation of OpenWrt, any lan client can access the router either by its lan IP, or by the openwrt.lan hostname. Isn't that what you want? There is no point in using the interface name, as any name resolving to a valid IP of the router will work. If you still insist in having a name lan for an IP of the router, you can add one in Hostnames

4 Likes

So Luci Web page can be accessed via HTTPS via
https://openwrt.lan
??
Can you provide any insight where and how this is implemented?

dnsmasq (respectively its uci/ procd instrumentation), hostname and domain definitions defaulting to those values.

Sorry, did not understand what you mean.
If you know the code location, I will be happy to understand it!