Add a new network interface in Rocky
Introduction
It is advisable to know how to use sed , uuidgen , unset
In brief
cd /etc/sysconfig/network-scripts/
cp ifcfg-enp0s3 ifcfg-enp0s8
MYUID=$(uuidgen enp0s8)
sed -i s/UUID=*/UUID=$MYUID/ /etc/sysconfig/network-scripts/ifcfg-enp0s8
sed -i s/NAME=*/NAME=enp0s8/ /etc/sysconfig/network-scripts/ifcfg-enp0s8
sed -i s/DEVICE=*/DEVICE=enp0s8/ /etc/sysconfig/network-scripts/ifcfg-enp0s8
ifup enp0s8
unset MYUID
Explanations
Suppose there is an interface enp0s3 and you need to create a new interface enp0s8
Go to directory /etc/sysconfig/network-scripts/ , which contains the interface settings.
cd /etc/sysconfig/network-scripts/
Copy the file of the existing interface to a file with the required name
cp ifcfg-enp0s3 ifcfg-enp0s8
Generate a new UID for the interface with uuidgen
MYUID=$(uuidgen enp0s8)
Replace the old names and UID with the new ones, using sed
sed -i s/UUID=*/UUID=$MYUID/ /etc/sysconfig/network-scripts/ifcfg-enp0s8
sed -i s/NAME=*/NAME=enp0s8/ /etc/sysconfig/network-scripts/ifcfg-enp0s8
sed -i s/DEVICE=*/DEVICE=enp0s8/ /etc/sysconfig/network-scripts/ifcfg-enp0s8
After that, it is advisable to clear the contents of the variable with unset
unset MYUID
Article author: Andrei Olegovich