Migrating custom network scripts to NetworkManager dispatcher scripts

Solution Verified - Updated -

Environment

Red Hat Enterprise Linux 8 before an upgrade to RHEL 9

Issue

RHEL 9 does not support the legacy network-scripts package that was deprecated in RHEL 8

Resolution

Before you can upgrade to RHEL 9, migrate your custom network scripts to NetworkManager dispatcher scripts.

If you cannot migrate to NetworkManager dispatcher scripts, use this documentation as a workaround: You can move the custom network scripts and write a NetworkManager dispatcher script that executes these existing custom scripts.

The example script in this procedure runs the /opt/network-scripts/ifup-local, /opt/network-scripts/ifup-pre-local, /opt/network-scripts/ifdown-local, and /opt/network-scripts/ifdown-pre-local scripts in an emulated environment.

Procedure:

1) Create the /opt/network-scripts/ directory:

# mkdir /opt/network-scripts/

2) Move your custom network scripts to /opt/network-scripts/:

# mv /sbin/if*-local /opt/network-scripts/

3) Create the /etc/NetworkManager/dispatcher.d/20-if-local file with the following content:

#!/bin/bash

test -n "$DEVICE_IFACE" || exit 0

run() {
    test -x "$1" || exit 0
    "$1" "$DEVICE_IFACE"
}                

case "$2" in 
    "up")   
        run /opt/network-scripts/ifup-local
        ;;      
    "pre-up")
        run /opt/network-scripts/ifup-pre-local
        ;;      
    "down") 
        run /opt/network-scripts/ifdown-local
        ;;      
    "pre-down")
        run /opt/network-scripts/ifdown-pre-local
        ;;      
esac

4) Set the permissions on the /etc/NetworkManager/dispatcher.d/20-if-local script:

# chown root:root /etc/NetworkManager/dispatcher.d/20-if-local
# chmod +x /etc/NetworkManager/dispatcher.d/20-if-local
# restorecon /etc/NetworkManager/dispatcher.d/20-if-local

5) If you require pre-up or pre-down events, create a symbolic link in the corresponding dispatcher directory:

# ln -s ../20-if-local /etc/NetworkManager/dispatcher.d/pre-up.d/
# ln -s ../20-if-local /etc/NetworkManager/dispatcher.d/pre-down.d/

6) Verify that the dispatcher script runs the custom scripts and that your network settings from the scripts were applied.

7) Proceed with the upgrade in Leapp.

Root Cause

The network-scripts package has been removed in RHEL 9. This package was deprecated in RHEL 8.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments