LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Assign multiple VLAN id to the same port (https://www.linuxquestions.org/questions/linux-networking-3/assign-multiple-vlan-id-to-the-same-port-4175440154/)

kinglizard86 12-05-2012 11:50 AM

Assign multiple VLAN id to the same port
 
Hi all,

is it possible to assign multiple VIDs to the same port using brctl and vconfig?

Suppose you have a linux box with three ethernet interfaces (eth0, eth1, eth2). I want to configure eth0 in trunking mode with VID 10,20,30 and put eth1 on VLAN 20 and eth2 on VLAN 30. This is achievable with the following commands:

Code:

vconfig add eth0 20
vconfig add eth0 30
brctl addbr br20
brctl addbr br30
brctl addif br20 eth0.20
brctl addif br20 eth1
brctl addif br30 eth0.30
brctl addif br30 eth2

This way packets tagged with 10 that arrives at eth0 are sent out untagged on eth1 and packets tagged with 20 that arrives to eth0 are sent out untagged on eth2.

Now if I want to assign both eth1 and eth2 also to VLAN 10 what should I do? And is it possible or not?

Thanks.

nini09 12-06-2012 12:13 AM

Yes, an interface can belong to multi VLAN and a VLAN can include multi interface.

kinglizard86 12-06-2012 03:23 AM

Ok. But, how can I practically achieve that with vconfig and brctl? I have different solutions in my mind, but all of them imply that one interface should belong to two bridges, and I know that this is not possible.
For example, I could create a third VLAN virtual interface on eth0:
Code:

vconfig add eth0 10
and a new bridge to handle that VLAN
Code:

brctl addbr br10
brctl addif br10 eth0.10

But I can't add eth1 or eth2 to br10 because they already belong to another bridge.

nini09 12-06-2012 02:10 PM

An interface can only be added into one bridge. Why do you want to add one interface into two bridge?

kinglizard86 12-06-2012 02:39 PM

I think that the way to handle VLANs in a linux box with multiple interfaces is to create one bridge for each VLAN you want to manage (e.g. br10, br20..)and then add to each bridge the interfaces you want to be on that VLAN. Maybe my hypothesis is wrong.
But I have another question. Suppose to have one interface belonging to two different VLANs. How untagged packets that enter to that interface are handled? Toward which VLAN are they forwarded?

nini09 12-07-2012 02:51 PM

Linux will support tagged and untagged interfaces. The eth0 interface is untagged. All vconfiged interfaces (eth0.n) are tagged. The untagged packets are handled by real physical interface.

eantoranz 12-07-2012 03:14 PM

This is some very nice crap that I haven't studied much in linux. That means you can have both tagged and untagged traffic going out of a single physical interface/link? Cool!

eantoranz 12-07-2012 03:16 PM

how about when you want to have one IP in certain vlan to which you have two interfaces connected? should bridge the vconfiged interfaces and set the IP address on the bridge, right?

nini09 12-09-2012 04:50 PM

Yes, you can have both tagged and untagged traffic on same physical interface.

kinglizard86 12-13-2012 03:47 AM

Quote:

Originally Posted by nini09 (Post 4843600)
Yes, an interface can belong to multi VLAN and a VLAN can include multi interface.

In order to belong to multiple VLAN an interface must be tagged. Otherwise, how does it know to what VLAN incoming untagged packets belong to?

nini09 12-13-2012 02:15 PM

That's why I say, the untagged packets are handled by real physical interface.


All times are GMT -5. The time now is 11:34 PM.