OpenWrt Forum Archive

Topic: [V] How to move Ethernet port to a separate LAN network?

The content of this topic has been archived on 30 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

TL-WR841ND has four LAN and one WAN port.
I need to split the LAN ports into two networks: 1, 2, 3 --> LAN 1 ||| 4 --> LAN 2
Here are the default configs for this router before my experiments:

swconfig dev switch0 show :

Global attributes:
        enable_vlan: 1
Port 0: # <<< Seems to be a "CPU port" (not a physical port)
        pvid: 1
        link: port:0 link:up speed:1000baseT full-duplex txflow rxflow 
Port 1:
        pvid: 1
        link: port:1 link:up speed:100baseT full-duplex auto
Port 2:
        pvid: 1
        link: port:2 link:up speed:100baseT full-duplex auto
Port 3:
        pvid: 1
        link: port:3 link:down
Port 4: <<<  Port which I want to move to a separate LAN
        pvid: 1
        link: port:4 link:up speed:100baseT full-duplex auto
VLAN 1:
        vid: 1
        ports: 0 1 2 3 4 

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 'XXXX:XXXX:XXXX::/XX'

config interface 'lan'
        option ifname 'eth0'
        option force_link '1'
        option type 'bridge'
        option proto 'static'
        option ipaddr '192.168.10.1'
        option netmask '255.255.255.0'
        option ip6assign '60'

config interface 'wan'
        option ifname 'eth1'
        option proto 'dhcp'
        option macaddr 'XX:XX:XX:XX:XX:XX'
config interface 'wan6'
        option ifname 'eth1'
        option proto 'dhcpv6'

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

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

One of my attempts - tried to replace "config switch_vlan" with the following:

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

config switch_vlan 'eth0_1'
    option device 'switch0'
    option vlan '2'
    option ports '4 5t'

but it caused the loss of connection for all the Ethernet connected PC's (could only restore /etc/config/network through WiFi) sad

Please, could you give a small example of how to move Port 4 to a separate network?

(Last edited by mward15 on 25 Dec 2016, 11:17)

Port 0 is the CPU port so you make it tagged in both VLANs.

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

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

Since the CPU is now tagged, refer to the two networks as eth0.1 and eth0.2.  Do not have a plain eth0 in any of the configurations.  So you need to change the ifname in lan to be eth0.1  Create a new lan2 and connect eth0.2 to it.

mk24 wrote:

Port 0 is the CPU port so you make it tagged in both VLANs.

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

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

Since the CPU is now tagged, refer to the two networks as eth0.1 and eth0.2.  Do not have a plain eth0 in any of the configurations.  So you need to change the ifname in lan to be eth0.1  Create a new lan2 and connect eth0.2 to it.

Thank you very much for helping, mk24! I have posted the final working configs to a thread with ID 69050 on this forum ( "[V] How to ban the Internet WAN traffic for a specific Ethernet port?" ) Have a great time ahead! smile

(Last edited by mward15 on 25 Dec 2016, 11:18)

The discussion might have continued from here.