1.8. NetworkManager and the Network Scripts

In previous Red Hat Enterprise Linux releases, the default way to configure networking was using network scripts. The term network scripts is commonly used for the script /etc/init.d/network/ and any other installed scripts it calls. The user supplied files are typically viewed as configuration, but can also be interpreted as an amendment to the scripts.
Although NetworkManager provides the default networking service, Red Hat developers have worked hard to ensure that scripts and NetworkManager cooperate with each other. Administrators who are used to the scripts can certainly continue to use them. We expect both systems to be able to run in parallel and work well together. It is expected that most user shell scripts from previous releases will still work. Red Hat recommends that you test them first.

Running Network Script

Run the script only with the systemctl utility which will clear any existing environment variables and ensure clean execution. The command takes the following form:
systemctl start|stop|restart|status network
Note that in Red Hat Enterprise Linux 7, NetworkManager is started first, and /etc/init.d/network checks with NetworkManager to avoid tampering with NetworkManager's connections. NetworkManager is intended to be the primary application using sysconfig configuration files and /etc/init.d/network is intended to be secondary, playing a fallback role.
The /etc/init.d/network script is not event-driven, it runs either:
  1. manually (by one of the systemctl commands start|stop|restart network),
  2. on boot and shutdown if the network service is enabled (as a result of the command systemctl enable network).
It is a manual process and does not react to events that happen after boot. Users can also call the scripts ifup and ifdown manually.

Custom Commands and the Network Scripts

Custom commands in the scripts /sbin/ifup-local, ifdown-pre-local, and ifdown-local are only executed when those devices are controlled by the /etc/init.d/network service. The ifup-local file does not exist by default. If required, create it under the /sbin/ directory.
The ifup-local script is readable only by the initscripts and not by NetworkManager. To run a custom script using NetworkManager, create it under the dispatcher.d/ directory. See the section called “Running Dispatcher scripts” for an explanation of the dispatcher scripts.

Note

Red Hat does not provide support if a user modifies any files included with the initscripts package or related rpms.
There are ways to perform custom tasks when network connections go up and down, both with the old network scripts and with NetworkManager. When NetworkManager is enabled, the ifup and ifdown script will ask NetworkManager whether NetworkManager manages the interface in question, which is found from the DEVICE= line in the ifcfg file. If NetworkManager does manage that device, and the device is not already connected, then ifup will ask NetworkManager to start the connection.
  • If the device is managed by NetworkManager and it is already connected, nothing is done.
  • If the device is not managed by NetworkManager, then the scripts will start the connection using the older, non-NetworkManager mechanisms that they have used since the time before NetworkManager existed.
If you are calling ifdown and the device is managed by NetworkManager, then ifdown will ask NetworkManager to terminate the connection.
The scripts dynamically check NetworkManager, so if NetworkManager is not running, the scripts will fall back to the old, pre-NetworkManager script-based mechanisms.

Running Dispatcher scripts

NetworkManager provides a way to run additional custom scripts to start or stop services based on the connection status. By default, the /etc/NetworkManager/dispatcher.d/ directory exists and NetworkManager runs scripts there, in alphabetical order. Each script must be an executable file owned by root and must have write permission only for the file owner. For more information about running NetworkManager dispatcher scripts, see the Red Hat Knowledgebase solution How to write a NetworkManager dispatcher script to apply ethtool commands.