Product SiteDocumentation Site

1.6. 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
Do not run any service by calling /etc/init.d/servicename start|stop|restart|status directly.
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. If you modified the initscripts themselves (for example, /etc/sysconfig/network-scripts/ifup-eth) then those changes would be overwritten by an initscripts package update. Therefore it is recommend that you avoid modifying the initscripts directly and make use of the /sbin/if*local scripts, so that your custom changes will survive package updates. The initscripts just check for the presence of the relevant /sbin/if*local and run them if they exit. The initscripts do not place anything in the /sbin/if*local scripts, nor does the initscripts RPM (or any package) own or modify those files.
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.