LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Adding/Removing VLAN Tag to an Incoming/Outgoing Packet (https://www.linuxquestions.org/questions/linux-networking-3/adding-removing-vlan-tag-to-an-incoming-outgoing-packet-4175582789/)

elcapitan 06-21-2016 08:25 PM

Adding/Removing VLAN Tag to an Incoming/Outgoing Packet
 
I want to be able to do following to an ethernet interface on a Ubuntu machine:

1. Add a 802.1Q VLAN tag to an incoming packet. The incoming packet can have an existing tag, so the new tag will be inserted in front of it. For example, I want every incoming packet from eth0 to have a new VLAN tag to be added.

Incoming Packet on eth0:
+---------------------------------------------------------------+
|DMAC|SMAC|Existing Tag|EthType| Payload |
+---------------------------------------------------------------+

gets modified to

+---------------------------------------------------------------+
|DMAC|SMAC|New Tag|Existing Tag|EthType| Payload |
+---------------------------------------------------------------+


2. Remove Outer Tag for outgoing packet. If the packet egressing the interface has a 802.1Q tag, it should be removed. There can be more than one tags on the interface, but only the outer tag should be removed.


Outgoing packet on eth0:

+---------------------------------------------------------------+
|DMAC|SMAC|Outer Tag|Inner Tag|EthType| Payload |
+---------------------------------------------------------------+

gets modified to when it gets out on the wire

+---------------------------------------------------------------+
|DMAC|SMAC|Inner Tag|EthType| Payload |
+---------------------------------------------------------------+

Are there any linux commands which will allow me to achieve this.

Thanks

jnihil 06-26-2016 02:27 AM

802.1ad (Q-in-Q) can be done with some fiddling around. Here's a good write-up and use-case:
http://events.linuxfoundation.org/si...makita_0_0.pdf

verde94 09-02-2021 05:42 PM

Removing vlan
 
Hi, sorry for reheating old topic. I'm facing similar issue. I can't find a solution. I have linux envirement, on one of it's interfaces frames with vlan tags or with no vlan tags can arrive. I want to remove vlan tag (any) from incoming frames if it belongs to certain ethertype (CFM) or certain MAC adress (more than one mostly macvlan but not only). How can I achive this "conditional" vlan tags tear off?
Thank you


All times are GMT -5. The time now is 12:23 PM.