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
|