I thing there was a time when your setting used to work, but I'm unsure if that broke by accident or was just removing unnecessary magigc.
Imho your setting creates a single interface eth0 which then gets configured according to your settings. Then this interface is referred to as lan, but it still is only eth0.
Your second setting tries to overwrite the configuration for eth0 and call the result lan2. It does not create a second interface but tries to apply the second network setting as well to the very same existing interface.
One way of dealing with it: An alias
You can create a new interface lan2 that doesn't use the physical ifname eth0 but just hooks onto the original lede interface lan and reuses the physical ifnames, no matter which interfaces are actually in use.
So the second interface lan2 is really a new interface that just happens to reuse the exact same ifname configuration as lan.
Another way of dealing with it: Bridges
config interface 'lan'
option type 'bridge'
option ifname 'eth0'
option proto 'static'
option ipaddr '10.20.10.20'
option netmask '255.255.255.0'
config interface 'lan2'
option type 'bridge'
option ifname 'eth0'
option proto 'static'
option ipaddr '10.20.10.20'
option netmask '255.255.255.0'
Those should create two different networks br-lan and br-lan2, both of type bridge, and both bridges should have a single member eth0. Here the network settings are not applied to eth0 directly but to br-lan and br-lan2.
I have a second ip on one router I'm running like you want. it's running a snapshot from back in Dec because it needed some hardware support not in trunk. I'm using it to access an ATT supplied vdsl modem...
@dlakelan, thanks - but are you sure that still works under LEDE? Tried that successfully (virtual iface) with Chaos Calmer, but didn't work under LEDE (not saying that has to work, since LEDE seems to clean the settings, I'd prefer it works only in one good way
@golialive Thank you. Will try that later this week end.
It is working right now under LEDE on the device I mentioned. It's a LEDE snapshot so it's possible that the stable version broke this and later the snapshot restored it... but I doubt it.
@golialive it seems the IP address in my case in properly received from the DHCP server (as shown in logread) but it is not shown by ifconfig. Funny thing is, it sort of works: I can ping the modem and access its gui from the lan.
Context: I have a DSL modem connected on the wan port, defined as such:
I have tried also using '@wan' but the result seems to be the same. In my previous router, with proper VLAN on WAN support, I had probably used 'eth0.2' for both "wan" and "modem" but other than that there is no other difference I can see. In that case, the IP for the modem interface would remain visible.
(previous: GL.inet MT750; current: Fritzbox 4040)
Is this to be expected? It's more a curiosity at this point than a real issue, of course.
The legacy ifconfig program will only show the first IPv4 address of an interface. You can use ip -4 addr show dev eth1 instead to show all IPv4 addresses on the eth1 interface.