I just wanted to quickly ask if there is an easy way to configure an DHCP-interface (i.e. wan) in such a way that it has a fixed IP address until it receives an DHCP-lease.
I've already tried setting proto to dhcp and setting ipaddr and netmask manually.
config interface 'wan'
option type 'bridge'
option ifname 'eth0'
option proto 'dhcp'
option netmask '255.255.255.0'
option ipaddr '192.168.100.100'
But this doesn't work. Is there any functionality built-in in openwrt I can use to archive this?
Im trying to let the interface have an fixed ip address as long as it has not received an dhcp-lease yet. When an dhcp-lease is received, it should switch to the received address and not answer on the fixed ip address.
How unfortunate. Which OpenWRT service/daemon handles the /etc/config/network file? I did not find a reference to the network-config in netifd for handling static/dhcp.
Its a fallback mechanism: If a device is somehow configured to receive its address via dhcp, but no dhcp-server is present in the network, I would like the device to have an fixed fallback ip where one can reach it with in case if no dhcp lease is received.
I don't think it's really part of the DHCP spec to be able to provide a specific 'fallback' IP. It'll fall back to addresses in the 169.254.0.0/16 (i.e. link-local) range, but other than that you'd probably have far more success just using a static IP from the outset if you want to ensure the interface can be reached regardless of the status of a DHCP server.
You could add a VLAN on that physical interface with a static IP (and DHCP disabled). Under normal circumstances, there wouldn't be any traffic on the VLAN. In the event that the DHCP interface doesn't get an IP, you could set your computer to a static IP on that VLAN (assuming your computer/OS is VLAN aware and has the ability to specify the VLAN) to access the router.
Have been setting up some small travel routers to use in a mesh configuration and would occasionally find myself "locked out" when reconfiguring and having to use console connection to fix. Ended up setting up a new bridge interface with a static IP and putting it on a VLAN and tagging the switch ports for it. If the mesh side of the network was inaccessible, I could connect with ethernet cable and statically configure an IP and VLAN tag on my host to access it. Much easier since accessing the serial connections requires disassembling the unit.