VLAN creation
First command creates a vlan with id 100 and assigns ip followed by vnic and iface up
ip link add link enp0s10 name vnic100 type vlan id 100
ip addr add 10.10.10.1/24 brd 10.10.10.255 dev vnic100
ip link set dev vnic100 up
ip link set dev enp0s10 up
Deletion of links
ip link delete qinq.vnic100
ip link delete vnic10
QinQ vnic creation
ip link add link enp3s0f0 name vnic10 type vlan id 10
ip addr add 10.10.10.1/24 brd 10.10.10.255 dev vnic10
ip link set dev vnic10 up
ip link set dev enp3s0f0 up
Another NIC on vnic100 that makes qinq i.e double tagged packets
ip link add link vnic10 name qinq.vnic100 type vlan proto 802.1Q id 100
ip link set dev qinq.vnic100 up
ip -4 addr flush dev qinq.vnic100
ip addr add 10.10.70.1/24 dev qinq.vnic100
Below arp entry to send packets on the nic by adding ARP entry
arp -s 10.0.70.20 00:10:10:10:10:10
Delete the QinQ in below order
ip addr flush dev enp3s0f0
ip link delete qinq.vnic100
ip link delete vnic10
Creating Namespace
First create the net name spaces with add and name, Then add the virtual interface to the namespace using ip link command. You can enter into the namespace with below command then after standard linux interface command
ip netns add ns0
ip link set dev enp1s0f0np0v0 netns ns0
ip netns exec ns0 bash
ifconfig -a
ifconfig enp1s0f0np0v0 10.10.10.10/24
ifconfig enp1s0f0np0v0 up
ifconfig lo up
Now check on functionality you can switch to netspace “ip netns exec ns0 bash” and do ping or you can perform via command “ip netns exec ns0 ping 10.10.10.2“