Automatic renumbering of LAN in case of conflict with WAN

Here's my attempt:
Idea:
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:

  • 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.
1 Like