Hi Rich,

Basic (v4 only) version of these (as well automatic wan proto detection) was 
implemented and rejected some years ago :)

Both are quite easy to do, that version used the following hotplug script:

===
#!/bin/sh

if [ "$INTERFACE" = "wan" ] && [ "$ACTION" = "ifup" ]
then
        # Get subnets for lan and wan
        lan_subnet=$(uci get network.lan.ipaddr | cut -d '.' -f3)
        wan_subnet=$(ifconfig wan | grep -w "inet" | awk '{print $2}' | cut -d 
':' -f2 | cut -d '.' -f3)

        # If subnet is the same, randomize lan IP
        if [[ $lan_subnet == $wan_subnet ]]; then
                rn=$(awk 'function rn(n) { return int(rand()*n); } BEGIN {{ 
srand(); }{ printf("%d.%d", rn(254), rn    (254    ))}}')
                uci set network.lan.ipaddr=10.$rn.1
                uci commit network

                # Restart network to refresh changes
                /etc/init.d/network restart
        fi
fi
===

Setup of redirection ran as an init script:

===
#!/bin/sh

START=55
boot() {

lanip=$(uci get network.lan.ipaddr)

grep -q "myrouter.local/$lanip" /etc/config/dhcp
if [ $? -eq 1 ] ; then
# add a redirect myrouter.local to our IP
        uci add_list dhcp.@dnsmasq[0].address="/myrouter.local/$lanip"
        uci commit dhcp
fi
}
===


Best,
Imre

________________________________________
From: openwrt-adm <[email protected]> on behalf of Rich 
Brown <[email protected]>
Sent: Monday, February 21, 2022 22:38
To: OpenWrt Project Administration; [email protected]
Cc: Richard E. Brown
Subject: Automatic LAN Subnet Reassignment

There is a new RFC on the OpenWrt forum proposing "Automatic LAN Subnet 
Reassignment" 
https://forum.openwrt.org/t/rfc-automatic-lan-subnet-reassignment-upon-conflict-with-wan/120938
 The RFC responds to the advice given at last week's OpenWrt-Adm meeting 
(https://etherpad.wikimedia.org/p/ZlZiTcud3wufcSX9-1jD)

The intent of the proposal is for the default configuration to assign a LAN 
subnet that avoids a conflict with the WAN subnet, and provide a mDNS name such 
at OpenWrt.lan for connections.

I have two requests:

1) Please make comments on the technical merits of the proposal on the OpenWrt 
forum at the link above.

2) If the proposal seems to make sense, please consider the process by which we 
would incorporate this into the main release (likely, not for 22.0x, but 
perhaps the next release?)

Thank you.

Rich



_______________________________________________
openwrt-adm mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-adm

_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to