How to set multiple network on OpenWrt 18.06.2

Please bear with me as I'm kind of noob in this routing thing

My openwrt router is Tp-link td8970 running OpenWrt 18.06.2


I have 2 source of internet on my network

  1. via 4g modem, usb modem on tplink 8970
  2. via cable on td8970
    I have 2 network on different subnet

what I need:
separate 2 route

  • any wired and wireless client within 2.0 network will get internet from td8970 via usb modem/4g
  • any wired and wireless client within 1.0 netwrok will get internet from wireless router (0.1) via wireless bridge 1.1
  • any request from openwrt itself will get internet from wireless router (0.1) via wireless bridge 1.1 (egg: if I'm using transmission to download torrent in the td8970 it will be using internet from wireless bridge)

So how is the correct procedure to do that simultanously. ?

At the moment I'm switching network mannually. If Im downloading using td8970 I switch gateway using ifconfig and route script

https://openwrt.org/docs/guide-user/network/ip_rules

1 Like
1 Like

Thanks for the responds. I will try read as much I can before another question.
bassically here is what I understand :slightly_smiling_face:
I need to set ip on openwrt in 1.0 network as a gateway (1.113 for example) and create SSID1, so interface need to be bridge ..
I need to set ip on openwrt in 2.0 network as a gateway (2.113 for example) and create SSID1, so interface need to be bridge

and here is what i was trying on spare openwrt ( its different version than my main rooter its 15.01 BB on tplink mr3220)

`============= no bridge ======

config interface 'lan'
option ifname 'eth0'
option proto 'static'
option ipaddr '192.168.1.113'
option netmask '255.255.255.0'

config interface 'lan2'
option ifname '@lan'
option proto 'static'
option ipaddr '192.168.2.113'
option netmask '255.255.255.0'

============= with bridge ======

config interface 'lan'
option ifname 'eth0'
option type 'bridge'
option proto 'static'
option ipaddr '192.168.1.113'
option netmask '255.255.255.0'

config interface 'lan2'
option ifname 'eth0'
option type 'bridge'
option proto 'static'
option ipaddr '192.168.2.113'
option netmask '255.255.255.0'`

both resulting the same thing. no ping on 2.113. only on 1.113.. not a complette /etc/config/network. Tried 17.01 using bridge but still the same result

root@LEDE:~# cat /etc/config/network

config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'

config globals 'globals'
option ula_prefix 'fd0b:cd50:fa5e::/48'

config interface 'lan'
option type 'bridge'
option ifname 'eth0'
option proto 'static'
option ipaddr '192.168.1.113'
option netmask '255.255.255.0'

config interface 'lan2'
option ifname 'eth0'
option type 'bridge'
option proto 'static'
option ipaddr '192.168.2.113'
option netmask '255.255.255.0'

config interface 'wan'
option ifname 'eth1'
option proto 'dhcp'

config switch
option name 'switch0'
option reset '1'
option enable_vlan '1'

config switch_vlan
option device 'switch0'
option vlan '1'
option ports '1 2 3 4 0'

without bridge I can ping both 1.113 and 2.113 just fine on 17.01

config interface 'lan'
#       option type 'bridge'
        option ifname 'eth0'
        option proto 'static'
        option ipaddr '192.168.1.113'
        option netmask '255.255.255.0'

config interface 'lan2'
        option ifname '@lan'
#       option type 'bridge'
        option proto 'static'
        option ipaddr '192.168.2.113'
        option netmask '255.255.255.0'


I am not sure if mwan3 is the way to go here because it will keep shifting from one to the other gateway and will not be routing both gateways at the same time or maybe thats my understanding of it.

I'd suggest you to create two entirely different networks, for Lan and for Wan. For example use existing Lan and Wan networks for internet through the 0.1 subnet.
Then you create Lan2 and Wan2 networks for 4G modem and assign your wireless interfaces accordingly to the networks in question.

Thanks Ahmar.
I thinks mwan does that...no multiple gateways simultanously..its switching from one wan to another wan.
So I set up multiple network on lan using ip alias non bridge method. Both pingable but cant bind ssid to those network yet.

According to the mwan3 description, it should be able route different sources to different gateways.
It would be strange if mwan3 can't do it simultanously.

I dont think if it's strange becasue mwan3 is supposed to route traffic when one WAN source is down or something like that. You can set up rules and then mwan3 would automatically route traffic according to those rules. But I think it is rather strange to route traffic from more than one WAN interfaces to a single LAN interface simultaneousy becasue then how would you know which public IP address you have.

Would it not be better to create two different networks as I suggested? This way you can assign Wifi and route internet traffic simultaneously to each of them. This also seems more simplistic to me. Of course not if alias type thing has more advantages?

Edit: It looks like mwan3 can also be used for OP's situation if I understand the mwan3 correctly. It states you can route different traffic to different sources and that is what OP wants in this case.

Im stuck at the moment...cant install mwan3 on my salvage router (mr3220 lede).

opkg install mwan3
Package ip-tiny version (null) has no valid architecture, ignoring.
Installing mwan3 (2.0.2-1) to root...
Downloading http://downloads.lede-project.org/releases/17.01.5/packages/mips_24k                                                                                        c/packages/mwan3_2.0.2-1_all.ipk
Collected errors:
 * parse_from_stream_nomalloc: Missing new line character at end of file!
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for mwan3                                                                                        :
 *      kernel (= 4.4.140-1-33d452ad71ac13bc6dc71df37efa5ec7) *         kernel (                                                                                        = 4.4.140-1-33d452ad71ac13bc6dc71df37efa5ec7) *         kernel (= 4.4.140-1-33d4                                                                                        52ad71ac13bc6dc71df37efa5ec7) *
 * opkg_install_cmd: Cannot install package mwan3.
root@LEDE:~# opkg install mwan3
Package ip-tiny version (null) has no valid architecture, ignoring.
Installing mwan3 (2.0.2-1) to root...
Downloading http://downloads.lede-project.org/releases/17.01.5/packages/mips_24kc/packages/mwan3_2.0.2-1_all.ipk
Collected errors:
 * parse_from_stream_nomalloc: Missing new line character at end of file!
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for mwan3:
 *      kernel (= 4.4.140-1-33d452ad71ac13bc6dc71df37efa5ec7) *         kernel (= 4.4.140-1-33d452ad71ac13bc6dc71df37efa5ec7) *         kernel (= 4.4.140-1-33d452ad71ac13bc6dc71df37efa5ec7) *
 * opkg_install_cmd: Cannot install package mwan3.

ubus call system board

What does it say?

Hi vgatera

ubus call system board
{
        "kernel": "4.4.140",
        "hostname": "LEDE",
        "system": "Atheros AR9330 rev 1",
        "model": "TP-Link TL-MR3220 v2",
        "board_name": "tl-mr3220-v2",
        "release": {
                "distribution": "LEDE",
                "version": "17.01.5",
                "revision": "r3919-38e704be71",
                "codename": "reboot",
                "target": "ar71xx\/generic",
                "description": "LEDE Reboot 17.01.5 r3919-38e704be71"

It seems that the opkg database is corrupted probably due to lack of free space.

Thanks vgaetera for pointing that out... i will salvage more decent router for testing. Possibly tomorrow

Ok Im getting decent router now tp-link wdr4300 on openwrt 18.06.2 atheros chipset.
mwan3 installed. will read and try it for now.
I did try the ip alias bridge and not and the result is the same : only pingable on non bridge (both network), on bridge its only pingable on 1.113

root@OpenWrt:~# cat /etc/config/network

config interface 'lan'
        option ifname 'eth0.1'
        option proto 'static'
        option netmask '255.255.255.0'
        option ipaddr '192.168.2.113'

config interface 'lan2'
        option ifname '@lan'
        option proto 'static'
        option ipaddr '192.168.1.113'
        option netmask '255.255.255.0'

In your example both interfaces shares the same subnetwork. You should separate networks, initially try to use IP not from the same subnetwork.

Please update to 18.06.4. The version you are running is outdated and has known vulnerabilities.

2 Likes

192.168.1.0/24 and 192.168.2.0/24 are different networks.
The problem is that they are assigned to one interface.
The OP should either split VLANs or configure static DHCP leases.

Yes, it's my mistake. I haven't used it, so what is option to use alias for interface with another IP? When can it be used?

This way it should be possible to assign IPs from different networks on one interface and create different DHCP pools with static leases, so a single L2 will host multiple L3.

Hi all ..here is my latest network config. with 2 vlan. I can ping wan (its 2.1) but cant ping lan2 (2.113). I plug the cable on port 1 and 4..which I hope its correct according to my vlan arrangement. `

root@OpenWrt:~# cat /etc/config/network

config interface 'lan'
        option type 'bridge'
        option proto 'static'
        option netmask '255.255.255.0'
        option ipaddr '192.168.2.113'
        option ifname 'eth0.1'

config interface 'LAN2'
        option type 'bridge'
        option proto 'static'
        option ipaddr '192.168.1.113'
        option netmask '255.255.255.0'
        option ifname 'eth0.1'

config interface 'wan'
        option proto 'static'
        option ipaddr '192.168.1.2'
        option netmask '255.255.255.0'
        option ifname 'eth0.3'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option vid '1'
        option ports '0t 2 3'

config switch_vlan
        option device 'switch0'
        option vlan '2'
        option vid '3'
        option ports '0t 4 5'`

so..what do I need to do..back to mwan3 or should I finish this 2 network setup first ?
thanks