I switched from Windows 10 to Fedora Linux (Plasma 5) on my work laptop a couple of months ago and I am quite happy with it so far. There are a few annoying things, like detaching and reattaching the laptop to the docking station causes the external displays to sometimes stay turned off. This does not happen every time but often enough to get frustrating. The only solution I found was to restart the whole system. I don’t know if this is a hardware compatibility related issue or if it’s just the software. Another “problem” I have, is the fingerprint reader. It does not work. Not much to add to that. Other than that, there are a few hiccups here and there. The taskbar sometimes (very rarely) freezes up for 10-30sec for instance. Everything else is working though. So nothing major I would say. The Laptop is a Lenovo T470 by the way. Great system otherwise.
Anyway, that’s not the reason I am writing this. The reason I am writing this is that lately I have been doing a lot of network stuff at work and I had several occasions where I needed a tagged VLAN interface on my laptop. Just to test things or if I wanted to access several networks (without routing) at the same time.
It is very easy to create one with “nmcli” (if you are using NetworkManager for your network). The problem is remembering the whole command. Also, I don’t think you can create multiple interfaces with one command. But let’s not get ahead of ourselves.
Let’s start with the normal way.
Creating VLAN Interfaces with nmcli
This command creates an interface with the VLAN id 20.
fedora-kde :: ~ » nmcli connection add type vlan con-name enp34s0.20 dev enp34s0 id 20 save no Connection 'enp34s0.20' (57b8a0b9-d46c-46ea-8a9f-38dea6bb2c0e) successfully added. fedora-kde :: ~ »
Let’s take a look at the interfaces.
fedora-kde :: ~ » nmcli connection show
NAME UUID TYPE DEVICE
enp34s0.20 57b8a0b9-d46c-46ea-8a9f-38dea6bb2c0e vlan enp34s0.20
enp34s0 8b05eb10-1bb7-3089-9e1c-84140df50c5d ethernet enp34s0
fedora-kde :: ~ » nmcli device
DEVICE TYPE STATE CONNECTION
enp34s0 ethernet connected enp34s0
enp34s0.20 vlan connecting (getting IP configuration) enp34s0.20
That’s it.
Deleting VLAN Interface with nmcli
This can be used to delete other interface types as well of course.
fedora-kde :: ~ » ./vlan-creation.sh -h
Usage:
Create:
vlan-creation.sh -i INTERFACE-NAME -v "VLANS" (Space separated) -s yes/no -u yes/no
Delete:
vlan-creation.sh -i INTERFACE-NAME -v "VLANS" (Space separated) -d
Example:
vlan-creation.sh -i ens0 -v "20 30" -s no -u yes
Options:
-h Help
-i Interface
-v VLAN IDs
-s Make configuration persistent yes or no
-u Disable Interface yes or no
-d Delete Interface
Keep in mind that this script has no failsafe of any kind. For instance, you could create a second interface with the same name and VLAN id. The script does not check for duplicates.
KDE Plasma 5. using the GUI to create VLAN Interfaces
One more thing. If you are using KDE Plasma 5 and want to use the GUI to create or just set an IP on the VLAN interfaces, you have to select “Show virtual connections” in the “Connections” Settings. Otherwise, the interfaces won’t show up.
Here is the script.
#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
## Variables
VLANS=""
INTERFACE=""
SAVE=""
DISABLE=""
usage () {
cat <<EOF
Usage:
Create:
vlan-creation.sh -i INTERFACE-NAME -v "VLANS" (Space separated) -s yes/no -u yes/no
Delete:
vlan-creation.sh -i INTERFACE-NAME -v "VLANS" (Space separated) -d
Example:
vlan-creation.sh -i ens0 -v "20 30" -s no -u yes
Options:
-h Help
-i Interface
-v VLAN IDs
-s Make configuration persistent yes or no
-u Disable Interface yes or no
-d Delete Interface
EOF
exit 0
}
OPTSTRING='hi:v:s:u:d'
while getopts ${OPTSTRING} flag; do
case "${flag}" in
h)
usage
exit 0
;;
i)
INTERFACE=$OPTARG
;;
v)
VLANS=($OPTARG)
;;
s)
SAVE=$OPTARG
;;
u)
DISABLE=$OPTARG
;;
d)
for item in ${VLANS[*]}
do
nmcli con del $INTERFACE.$item
done
exit
;;
:)
echo "$0: Must supply an argument to -$OPTARG." >&2
exit 1
;;
\?)
echo "Invalid option: -$OPTARG" <&2
exit 1
;;
esac
done
for item in ${VLANS[*]}
do
nmcli con add type vlan con-name $INTERFACE.$item dev $INTERFACE id $item save $SAVE
if [ $DISABLE = "yes" ]
then
nmcli con down $INTERFACE.$item
fi
done
We use cookies to optimize our website and our service.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes.The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.