• We did not send an email asking for donations - please read this post.

CentOS/RHEL preserve "ip link set" settings

MattSimpson

New Member
Joined
Jun 27, 2022
Messages
7
Reaction score
1
Credits
64
Hi All,
I hope you are doing well during these a bit strange times.
I stumbled upon this issue where the only way to configure some of the settings I can do through ip set link command.
This is to do with virtual adapters with VLANs with vf and proto 802.1Q parameters.
This requires bringing down an interface at startup then to break to virtual ports.
Something like this:
Code:
ip link set ens2s0f0np0v0 down
ip link set ens2s0f0np0v1 down
ip link set ens2s0f0 vf 0 vlan 200 proto 802.1Q
ip link set ens2s0f0 vf 1 vlan 201 proto 802.1Q
ip link set ens2s0f0np0v0 up
ip link set ens2s0f0np0v1 up
ip link set ens2s0f0 vf 0 trust on
ip link set ens2s0f0 vf 1 trust on

What is the best / safest place to put this in a script? This must be after the whole network stack is up.
 


f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
4,959
Reaction score
3,601
Credits
36,138
You could create a systemd-unit file for it, as type "oneshot" and add those lines to a file to execute.
Code:
[Unit]
Description=VLAN adapters
After=network.target network-online.target

[Service]
Type=oneshot
ExecStart=/usr/local/sbin/start_vlan.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
Although I think the better option would be to do it this way?
 
OP
M

MattSimpson

New Member
Joined
Jun 27, 2022
Messages
7
Reaction score
1
Credits
64
Yes I was looking into doing it via SystemD but it looks like doing it via network-scripts is even cleaner. I haven't seen this done with network-scripts before.
Thank you
 
OP
M

MattSimpson

New Member
Joined
Jun 27, 2022
Messages
7
Reaction score
1
Credits
64
I think you could do all of this in NetworkManager.

The thing is when I use the nmcli command the new port looks different.
When I run
nmcli con show the connection created with the commands above look like this
Code:
NAME: Wired connection 2, UUID, TYPE: Ethernet, DEVICE: ens2f0v1
but with command nmcli con add type vlan con-name VLAN100 dev ens2f0 id 100
Code:
NAME: VLAN100, UUID, TYPE: vlan, DEVICE: ens2f0.100

Not sure what is the difference between this approach and setting it up with SR-IOV VF (virtual function).
 
OP
M

MattSimpson

New Member
Joined
Jun 27, 2022
Messages
7
Reaction score
1
Credits
64
I think I found the correct syntax for NMCLI
Code:
nmcli con add type ethernet con-name EthernetPF ifname ens2f0
nmcli con modify EthernetPF sriov.total-vfs 3 sriov.autoprobe-drivers false
nmcli con modify EthernetPF sriov.vfs '0 mac=00:11:22:33:44:55 vlans=10, 1 trust=true spoof-check=false'
 
Last edited:
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Members online

No members online now.

Top