RFC: Automatic LAN subnet reassignment upon conflict with WAN

Continuing a conversation from here as an RFC for implementation (per @richb-hanover-priv in this comment).

Abstract:
Method of automatic LAN network reassignment upon conflict with WAN

Purpose:
Prevent a conflict where the LAN and WAN occupy the same or overlapping subnets.
This issue will cause routing to fail. Most often impacts novice/new OpenWrt users when they connect an OpenWrt device to an existing network using the common 192.168.1.0/24 subnet.
Can also impact road-warrior type users with travel routers since the upstream network may be unknown and may change frequently based on the location.

Assumptions:

  • Network configuration exists with one LAN and one WAN.
  • WAN uses DHCP client or PPPoE for address assignment.
  • LAN uses static IP.
  • Upstream network will be a properly configured RFC1918 IP such that there will always be some RFC1918 address that is available.
  • If upstream network is publicly routable or CG-NAT, this issue will not present.

Basic Logical Flow:

  • On boot, do not bring up LAN interface until WAN is up with an address or an n-second timeout has occurred without a WAN address assignment.
  • If WAN is not up, continue with ifup for LAN.
  • The following occurs when WAN comes up (maybe as a hotplug event):
    -- Evaluate the WAN's assigned IP address AND subnet
    ---- If upstream is publicly routable or CG-NAT, do nothing.
    ---- If WAN has RFC1918 address, calculate the upstream network range.
    ---- Compare the LAN (address + subnet) with that of the WAN network. If no collision/overlap occurs, do nothing.
    ---- If there is a conflict, assign an alternate IP/subnet to the LAN.
    ------- Bounce LAN related interfaces (ethernet and/or wifi, if enabled) to cause new DHCP client requests.

Basic Functional Configuration Elements:

  • LAN subnet reassignment would only be triggered upon a conflict with the WAN.
  • Preferred LAN address/subnet (default value 192.168.1.1/24)
  • Alternate LAN address/subnet (default value: ideally any /24 from RFC1918 10.0.0.0/8 or 172.16.0.0/12 ranges)
  • Enabled on the default installation of OpenWrt (some future major release version).
  • Option to cover additional WAN networks (to allow multi-wan and/or VPN upstream coverage).
  • Option to disable this feature.
  • Possible feature: automatic update of the preferred LAN address if the user changes the LAN in /etc/config/network)
  • User configurable alternate LAN addresses, list of any number of elements allowed.
  • Option to enable random address assignment in the event that the above list does not prevent conflict.

Not Covered:

  • VLANs/multiple LANs would not be covered.
    -- It is likely a reasonable assumption that this is not common for a road-warrior travel router config, and most likely users implementing multiple networks would know to avoid conflicts.
  • No guarantees about forcing DHCP renewals after LAN address change.
    -- Bouncing the LAN interfaces should work, but will not help for devices that are not directly connected (i.e. via a downstream switch or AP).
  • Cannot force reassignments of static IP based hosts (obviously).
  • May cause issues with static DHCP host assignments.

Other:

  • All configuration would be in a new config file (i.e. /etc/config/auto_lan_address or similar)
  • Update documentation to indicate that https://openwrt.lan is the easiest way to access router
  • Update documentation to indicate the default address for the alternate LAN address.
  • Update documentation to describe options, parameters, operating principle of this feature.

Comments welcome, of course (that's why it is an RFC :slight_smile: ). But since this is the continuation of a previous topic (linked above), please see that thread for the historical discussion. My hope is that this specific thread will focus more on arriving at a go/no-go decision, technical implementation details and documentation. Obviously there is a political element here as far as changing a core OpenWrt behavior, so that is also fair game. But hopefully we won't end up with a duplicate set of comments here compared to the existing thread.

3 Likes

Excellent job specifying the proposal! Thanks!

I submitted this to the OpenWrt-adm and OpenWrt-devel lists for discussion. You can follow the discussion on this topic or via either of these links:

http://lists.openwrt.org/pipermail/openwrt-adm/2022-February/thread.html
http://lists.openwrt.org/pipermail/openwrt-devel/2022-February/thread.html

1 Like

Hello,
For a home network, RFC8375 recommends to use a domain name ending with '.home.arpa.'

The IANA has registered the domain name 'home.arpa.' in the "Special-Use Domain Names" registry.

I think we should also introduce different default metrics for WAN and LAN to ensure a functioning LAN even in the conflict case.

1 Like

I have something like this functioning on my routers and it works well. On boot I wait for a WAN address to be assigned. If that conflicts with my LAN subnet, then I renumber the LAN and reboot.

What I have not implemented is hooking to receive notification that the WAN has been unplugged and then renumbered when plugged in somewhere else.

But great idea to make this super easy for beginners, so that it does the work automatically.