-
Notifications
You must be signed in to change notification settings - Fork 0
Persistent Configuration
Sometimes it is desirable to have the network configuration persist
across reboots. This section describes how to achieve that using
systemd
.
This section assumes systemd
is used as the service manager on the
system and that NetworkManager
is disabled. To disable
NetworkManger
, which is mainly aimed at desktop environments, run:
$ systemctl disable NetworkManager
In addition, systemd-networkd
needs to be enabled:
$ systemctl enable systemd-networkd
To prevent systemd
from waiting until all the links are configured,
edit the following file as specified below:
# /usr/lib/systemd/system/systemd-networkd-wait-online.service
...
ExecStart=/usr/lib/systemd/systemd-networkd-wait-online -i <mgmt>
...
Where <mgmt>
is replaced with the name of the management interface
(e.g., enp0s20f0). This will make systemd
only wait for the management
interface to be configured and gain carrier.
To split a port during system initialization and have the configuration
persist across reboots, it is possible to use a systemd
service unit
file.
# /etc/systemd/system/split-port@.service
[Unit]
Description=Split port sw1p%i by 4
Documentation=man:devlink-port(8)
After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/devlink port split sw1p%i count 4
ExecStop=/usr/sbin/devlink port unsplit sw1p%is0
[Install]
WantedBy=multi-user.target
The above service will split port sw1p12
by 4 when executed:
$ systemctl start split-port@12
And unsplit the port when stopped:
$ systemctl stop split-port@12
To have the port split during system initialization, enable the
port-split
service:
$ systemctl enable split-port@12
The previously described method will not automatically split the port in case the driver is removed and then loaded again.
It is possible to automatically split the port when it appears using
udev
:
# /etc/udev/rules.d/10-local.rules
SUBSYSTEM=="net", ACTION=="add", ATTR{phys_switch_id}=="<phys_switch_id>", \
ATTR{phys_port_name}=="p12", ENV{SYSTEMD_WANTS}="port-split@12.service"
# /etc/systemd/system/port-split@.service
[Unit]
Description=Split port sw1p%i by 4
Documentation=man:devlink-port(8)
[Service]
Type=simple
ExecStart=/usr/sbin/devlink port split sw1p%i count 4
systemd
can configure many aspects of the network. To see the full
list of possible configuration options please refer to the Further
Resources section.
The example below shows how to create a VLAN-aware bridge between two switch ports.
# /etc/systemd/network/25-bridge.netdev
[NetDev]
Description=Simple VLAN-aware bridge
Name=br0
Kind=bridge
[Bridge]
DefaultPVID=1
VLANFiltering=true
# /etc/systemd/network/25-bridge.network
[Match]
Name=br0
[Network]
Address=192.0.2.1/24
# /etc/systemd/network/25-bridge-slave-1.network
[Match]
Name=sw1p1
[Network]
Bridge=br0
# /etc/systemd/network/25-bridge-slave-2.network
[Match]
Name=sw1p3
[Network]
Bridge=br0
To make the changes take effect, start the systemd-networkd
service:
$ systemctl start systemd-networkd
Assuming the service is enabled, the configuration will persist across reboots.
- man systemd-networkd
- man systemd.network
- man systemd.netdev
Installation
System Maintenance
Network Interface Configuration
- Switch Port Configuration
- Persistent Configuration
- Quality of Service
- Queues Management
- Port Mirroring
- ACLs
- OVS
- Resource Management
Layer 2
Network Virtualization
Layer 3
- Static Routing
- Virtual Routing and Forwarding (VRF)
- Tunneling
- Multicast Routing
- Virtual Router Redundancy Protocol (VRRP)
Debugging