Configuring VLAN and IPTV on Nanopi R4S

Hi! Sorry in advance for my lack of knowledge, I'm trying as best as I can.

I'm currently using an Archer C7 on openwrt as the main router for my pppoe internet connection, which uses VLANs 500 for internet, and 600 for iptv. My iptv box is connected on port 4. I'm now trying to upgrade to an R4S flashed with openwrt as my main router, and use the existing C7 as a managed switch, connected to the LAN port of the R4s. I've been trying to get my iptv to work, but I haven't been successful, and the R4S doesn't have a switch section in it's GUI (at least in openwrt), and I'm not experienced with editing configs through SSH, so I have no idea how to do this on the R4S, or if this is even possible.

this is my current network config on the Archer C7, where iptv is working on port LAN 4:

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

config globals 'globals'
        option ula_prefix 'fd4f:f09c:4bb4::/48'

config device
        option name 'br-lan'
        option type 'bridge'
        list ports 'eth0.1'

config interface 'lan'
        option device 'br-lan'
        option proto 'static'
        option netmask '255.255.255.0'
        option ip6assign '60'
        option ipaddr '192.168.1.2'

config device
        option name 'eth0.2'
        option macaddr 'b0:be:76:59:b5:bb'

config interface 'wan'
        option proto 'pppoe'
        option username xxxxxx
        option password xxxxxxx
        option ipv6 'auto'
        option device 'eth0.500'

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

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

config switch_vlan
        option device 'switch0'
        option vlan '2'
        option vid '600'
        option description 'hypptv'
        option ports '5 1t'

config device
        option type '8021q'
        option ifname 'eth0'
        option vid '500'
        option name 'eth0.500'

config switch_vlan
        option device 'switch0'
        option vlan '5'
        option ports '0t 1t'
        option vid '500'
        option description 'internet'

any help would be greatly appreciated.

Not a trivial task, but it should be possible.
Please post the r4s network config using uci show network.

root@OpenWrt:~# uci show network
network.loopback=interface
network.loopback.device='lo'
network.loopback.proto='static'
network.loopback.ipaddr='127.0.0.1'
network.loopback.netmask='255.0.0.0'
network.globals=globals
network.globals.ula_prefix='fd01:23f4:2b9f::/48'
network.@device[0]=device
network.@device[0].name='br-lan'
network.@device[0].type='bridge'
network.@device[0].ports='eth1'
network.lan=interface
network.lan.device='br-lan'
network.lan.proto='static'
network.lan.ipaddr='192.168.1.1'
network.lan.netmask='255.255.255.0'
network.lan.ip6assign='60'
network.wan=interface
network.wan.device='eth0'
network.wan.proto='dhcp'
network.wan6=interface
network.wan6.device='eth0'
network.wan6.proto='dhcpv6'

this is after resetting the r4s to its default settings

The good news: it's more than possible. OpenWrt was made for things like an R4S as a main gateway router with an Archer C7 as a managed switch and dumb AP. This will be a great home network arrangement. Your R4S can handle all the CPU heavy stuff like Gigabit routing, SQM traffic shaping and VPN's, while the CPU on your C7 will be far happier for only needing to worry about WiFi. But it is also going to send you to networking school ;-). With greater capability comes greater complexity.

The R4S does not have a switch - just two ports, no switch. The R4S network configuration file uses DSA syntax to set up vlans, not swconfig. Unfortunately, OpenWrt hasn't been migrated to DSA yet (DSA manages switches too) for ath79 targets like your Archer C7, so you'll need to wade through both DSA and swconfig to configure your new network.

I use a NanoPi as my home gateway router that is set up to manage several VLANs (guest, IOT, etc.), with a GS308T managed switch (DSA in OpenWrt) and a couple LinkSys EA8500's (still swconfig like your C7) wired to the GS308T switch serving as dumb AP's. I've not had to mess with setting up VLAN's for IPTV and PPPOE before, but I've posted the my configuration details in other threads on this forum (probably when I was still using an ER-X on DSA for my gateway), which should give you a bit of a start. Not exactly what you are doing, but close enough to get you on the right path I think.

Assuming eth0 is the modem and eth1 is the TV box, first change the wan device to eth0.500 so that wan (internet) packets are tagged 500.

Then since there's no hardware switch, set up a software bridge for TV packets:

config device
    option name 'br-iptv'
    option type 'bridge'
    list ports 'eth0.600'
    list ports 'eth1'
config interface 'iptv'
    option device 'br-iptv'
    option proto 'none'

The proto none (called "unmanaged" in LuCI) interface means that the TV packets are not going to be processed by the OpenWrt kernel other than to copy them through the bridge. But it is necessary to declare a companion interface or the bridge won't be created at all.

Generally with a one or two port Pi type router you'll want to buy an external managed switch for expanding the wired network. The R4S is not DSA and never will be DSA since there's no hardware linkage that bypasses the CPU to send data directly between ports. Each port is connected independently to the CPU, so software must be used to "switch" traffic between them. This is not a big deal with a powerful CPU; using the TV is unlikely to have any noticeable loading effect.

Yes. But isn't the syntax used in the network configuration file for using software to switch traffic between the NanoPi ports, handle vlans, bridges, etc. essentially the same syntax that would be used on OpenWrt devices with real physical switches that have been converted to DSA? Or do I have this wrong?

The DSA syntax is intended to give the appearance of individual independent ports, even though the hardware is actually one port and a switch. DSA is also supposed to optimize the use of that hardware by installing hardware switching whenever possible. That is still being worked out.

I'm really sorry but do i set this on the R4S or the C7?

This is for the R4S. I thought you were replacing the C7 with an R4S. Does the configuration that you posted for C7 actually work with your network?

Sorry, yes, it'll replace the C7, which should be able to be a managed switch right? The C7 config i posted is the working one I'm using right now, with the C7 as the router.

Yes you could configure your C7 to be a managed switch and wifi AP and do routing in the R4S.
In that case, TV packets need never enter the R4S. The C7 switch would switch them directly from the TV box to the modem.

1 Like

This topic interests me. I have exactly these two devices (R4S and C7) and would like to create 2 VLANs on them. E.g. Guest and IOT. C7 is Dump AP for Wi-Fi.

This post may help you get started:
https://forum.openwrt.org/t/help-with-openwrt-router-3-dumb-access-points-vlan-setup/122123/3?u=eginnc

1 Like

The main NanoPi difference from the linked example will be that it has only a single non-wan port, that being eth1, to send the untagged lan vlan 1 and tagged vlans 10, 20 and 30 for IOT1, IOT2 and GST, respectively, to in the linked example.

Also in the linked example, I notice I have the vlans (1, 10, 20, 30 for lan, IOT1, IOT2 and GST) only set up as coming in on port 1 of the dumb AP for wireless availability. For using the dumb AP as a switch and AP with the NanoPi, you'll want to list out the rest of your physical ports. For example, you might change this:

config switch_vlan
	option device 'switch0'
	option vlan '1'
	option ports '1 6t'
	option vid '1'

to this:

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

if you want devices plugged into ports 2, 3 and 4 on your dumb AP to have access to the lan vlan (vlan 1). Similarly, add ports 2, 3 and/or 4 to the "option ports '1t 6t' line in the sections for the tagged IOT1, IOT2 and GST vlans in the linked example if you want those available to other ethernet ports too. And port 6 may not be the CPU port on the C7, so adjust accordingly for your device of course.

Finally I will share that on the gateway device (NanoPi in this case) using DSA syntax, I often forget to add the ".1" to br-lan here:

config interface 'lan'
	option device 'br-lan.1'
	option proto 'static'
	option ipaddr '10.10.10.1'
	option netmask '255.255.255.0'
	option ip6assign '60'

It gets me every time, but hopefully you less often now.

1 Like

I know this is late, but if ur still looking for answers, user @pavelgl really helped me fix my setup with the exact models as you mentioned, so you can try asking him. I'd post the configs here, but it's quite complicated and my config might differ from what you want.