2.6. Using NetworkManager with Network Scripts
network scriptsrefers to the script
/etc/init.d/networkand any other installed scripts it calls. Although NetworkManager provides the default networking service, scripts and NetworkManager can run in parallel and work together. Red Hat recommends to test them first.
Running Network Script
The systemctl utility clears any existing environment variables and ensures correct execution.
/etc/init.d/networkchecks 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/networkis intended to be secondary.
- manually - using one of the
- on boot and shutdown if the network service is enabled - as a result of the
systemctl enable networkcommand.
systemctl reload network.servicecommand does not work due to technical limitations of initscripts. To apply a new configuration for the network service, use the
~]#This brings down and brings up all the Network Interface Cards (NICs) to load the new configuration. For more information, see the Red Hat Knowledgebase solution Reload and force-reload options for network service.
systemctl restart network.service
Using Custom Commands in Network Scripts
ifdown-localscripts are only executed if these devices are controlled by the
ifup-localfile does not exist by default. If required, create it under the
ifup-localscript 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”.
network scriptsand with NetworkManager. If NetworkManager is enabled, the
ifdownscript will ask NetworkManager whether NetworkManager manages the interface in question, which is found from the “DEVICE=” line in the
- calling ifup
- When you call
ifupand the device is managed by NetworkManager, there are two options:
- If the device is not already connected, then
ifupasks NetworkManager to start the connection.
- If the device is already connected, then nothing to do.
- calling ifdown
- When you call
ifdownand the device is managed by NetworkManager:
ifdownasks NetworkManager to terminate the connection.
ifdown, the script starts the connection using the older, non-NetworkManager mechanism that it has used since the time before NetworkManager existed.
Running Dispatcher scripts
/etc/NetworkManager/dispatcher.d/directory exists and NetworkManager runs scripts there, in alphabetical order. Each script must be an executable file owned by
rootand must have
write permissiononly 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.