OpenWrt Forum Archive

Topic: [solved] Setting up a non-switch vlan device/interface

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

I am trying to configure a vlan interface on the wan port of my router, not connected with the internal switch. On this particular model, the wan port is stand-alone and not part of the switch. As per the documentation, I have added the following to /etc/config/network (eth1 is the wan interface):

config device 'eth1.20'
       option type '8021q'
       option name 'eth1.20'
       option ifname 'eth1'
       option vid '20'

This doesn't seem to do anything. After rebooting the router, the vlan interface doesn't exist:

root@OpenWrt:/etc/config# ifconfig eth1.20 up
ifconfig: SIOCGIFFLAGS: No such device

Is there another way to create a vlan on one of the ports? Am I doing it wrong?

The specs are:
TP-Link TL-WR841N v.11.1
Openwrt DESIGNATED DRIVER (Bleeding Edge, 49928)

(Last edited by xj25vm on 10 Oct 2016, 09:59)

Have you tried using the device in an interface config? BTW interfaces are brought up and down with "ifup <name>", "ifdown <name>".

I have tried adding the device in an interface config - and that doesn't work either. If I only add eth1.20 in an interface config, but I *don't* add the device section - it does create the eth1.20 device automatically - but as far as I can tell, it is not a vlan device.

Can anyone confirm that the "device" stanza still works on current versions of OpenWRT - after the move has been made away from "vconfig" to using the iproute2 command for setting up vlan's?

Edit: Hmm - the plot is thickening. I can create the vlan interface on the command line:

# /sbin/ip link add link eth1 name eth1.20 type vlan id 20

Then I can bring it up with ifconfig and it shows in the list of interfaces:

# ifconfig eth1.20 up

But if I try ifup, it doesn't detect it exists:

# ifup eth1.20
Interface eth1.20 not found

(Last edited by xj25vm on 3 Oct 2016, 13:09)

OK, I  can confirm that in a current snapshot, the following doesn't work:

config device 'eth1.20'
       option type '8021q'
       option name 'eth1.20'
       option ifname 'eth1'
       option vid '20'

Actually, after reboot, it leaves my router in an unknown state and I can't reconnect to it. I have to reset it completely to get back in.

However, just adding the eth1.20 to any interface section - without defining it separately as a device - seems to automatically create the vlan interface. For example, turning the wan interface into a bridge:

config interface 'wan'
        option type 'bridge'
        option ifname 'eth1.20'
        option proto 'dhcp'

... and now checking it is really a vlan interface (after installing the package ip-full, as the ip command included in BusyBox is more limited):

ip -d link show eth1.20
7: eth1.20@eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-wan state UP mode DEFAULT group default qlen 1000
    link/ether c4:e9:84:97:03:7d brd ff:ff:ff:ff:ff:ff promiscuity 1 
    vlan protocol 802.1Q id 20 <REORDER_HDR> 
    bridge_slave state forwarding priority 32 cost 19 hairpin off guard off root_block off fastleave off learning on flood on addrgenmode eui64 

Maybe the Wiki needs updating to remove the instructions regarding creating a vlan device separately - unless I've missed something above?

(Last edited by xj25vm on 12 Jul 2017, 18:22)

xj25vm wrote:

Maybe the Wiki needs updating to remove the instructions regarding creating a vlan device separately - unless I've missed something above?

Can I ask what type of WAN are you using? I want to do something similar to connect to my IPoE WAN provider (fibre to the home) and am hoping this method will work.

Can I ask what type of WAN are you using

Actually the wan port of the router in question is not connected to an actual wan network. It is connected to an internal network. It's just that I needed to use the physical wan port of the router in my config - with a vlan attached to it.

On the other hand, I'm not sure I understand what you are trying to achieve. If you are going to create a vlan on your actual wan port - is there a vlan switch at the provider end, to process all those vlan packets they are going to receive from your end?

Use 'ifname eth1.20'.  That actually activates a VLAN on the port.  'name' is just the convenient name that appears in the list.

A VLAN on the WAN cable is commonly needed with fiber to the home and some DSL modems.

When you start using VLANs, be sure you don't have plain 'eth1' left over in your configuration anywhere.

(Last edited by mk24 on 12 Jul 2017, 15:41)

Use 'ifname eth1.20'.  That actually activates a VLAN on the port.  'name' is just the convenient name that appears in the list.

Would that be in a 'device' or 'interface' section in /etc/config/networks?

A VLAN on the WAN cable is commonly needed with fiber to the home and some DSL modems.

Interesting - I wasn't aware of that.

When you start using VLANs, be sure you don't have plain 'eth1' left over in your configuration anywhere.

In my case I needed both eth1 and eth1.20 (but in different 'interface' sections) - because my setup uses both tagged and untagged packets on the eth1 interface - each using different IP pools. But I guess other setups, such as some DSL modems or fibre to the premises might only use tagged packets.

The discussion might have continued from here.