OpenWRT with SUB-Interface

Hi OpenWRT Forum Team:

We have a Ubiqiuti ER-X router: running OpenWRT 19 (router 2)

Things are going good using OpenWRT on the Ubiquiti ER-X routers!

QUESTION:
Can someone help with the correct SYNTAX to use in /etc/config/network so that:
We can have a sub-interface (2nd IP address) (router 2)

/etc/config/network

We are using the normal layout:
1-WAN port (far left port)
3-LAN ports (bridge of all remaining ports) (3 or 4)

The current LAN IP is: 192.168.100.1/24

We would like the "LAN bridge" to have a 2nd IP address (sub-interface) of:

192.168.200.5/24 (router 2)

GOAL:
We would like this router to have a 2nd IP so we can reach another LAN running on a 2nd Ubiquiti ER-X router (with OpenWRT) (router 1)

Other LAN: 192.168.200.1/24 (router 1)

We have a short yellow 5' CAT-5e Ethernet cable running between the (2) routers.
This cable is in port 2 (1st open LAN port) (same on both routers) (router 1 and 2)

We want to be able to ping from 192.168.200.5 (router 2) over-to 192.168.200.1 (router 1)

We were not sure if we needed to only edit /etc/config/network and/or if we also needed to add a static route on router 2

We have not changed any of the settings on router 1.

Also, when one makes a change in /etc/config/network ...
Is there a way to reload these settings without having to REBOOT the device?

Thank you for any tips/advice

In uci cli syntax:

uci del network.lan.ipaddr
uci del network.lan.netmask
uci set network.lan.ipaddr=192.168.100.1/24
uci add_list network.lan.ipaddr=192.168.200.5/24
uci commit network 
ifup lan

In config file syntax:

config interface lan
  option proto static
  option device …
  list ipaddr 192.168.100.1/24
  list ipaddr 192.168.200.5/24

Idea is to switch from single ip + netmask notation to list of CIDR notation to be able to specify an arbitrary amount of addresses.

Note that busybox ifconfig is limited and not able to show secondary addresses, use ip -4 addr show to verify.

To reload network settings without reboot, you can either use ifup -a or ubus call network reload.

A more generic solution is using the /sbin/reload_config command which should work for all kinds if uci configs, not just network.

1 Like

Hi Jow:

Thank you.
Your steps worked!

We now have a sub-interface.
We have (2) LAN IP addresses on the OpenWRT router.

GREAT help.

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