Automatic renumbering of LAN if WAN conflicts

Hi,

I am putting together a firmware for routers that will be deployed onto private networks. One problem I have run into is that the IP address range chosen for the br-lan network may be the same as that used by the network I am connecting to. i.e. my LAN range is 192.168.1.0/24, but my wan interface also gets an address in the same range.

I'm looking at the best way to handle this, and have come across the /etc/hotplug.d/iface directory, where scripts will be run when the interface comes up. So my theory is to create 10-renumber-lan that checks whether the IP address assigned to the wan interface is in the range of any other defined networks. I guess I can do a uci foreach to iterate through the defined networks, and compare.

So, my question then is: what is the OpenWrt way of checking whether an IP is within a network range? Or, alternatively, does anyone have better suggestions on how to handle this?

1 Like

Why not build it with your own lan IP by default?
I am sure no other network will be using 172.29.223.1/24

1 Like

@RoganDawes
I don't think it's a good idea. The default IP address of the LAN interface should be fixed. You don't want it to be subject to connecting it to an upstream router.

If you want to avoid possible conflict, you can just choose a different LAN IP other than what people usually do.

1 Like

Yeah, I guess you are right. Something in the 10.*.* range is extremely unlikely to conflict.
My reasoning was that because I am using go-http-tunnel to provide remote access to the router, my priority is actually to have internet access, rather than having the LAN network numbering be consistent. But I guess I can have both, if I choose a random network rather than 192.168.0.0 or 192.168.1.0

2 Likes

It's not just about consistency. It makes troubleshooting more difficult if the LAN IP is questionable.

2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.