Linux OS Service ‘NetworkManagerDispatcher’

The NetworkManager daemon attempts to keep an active network connection available at all times. The NetworkManager facility offers a tool called NetworkManagerDispatcher which executes commands in /etc/NetworkManager/dispatcher.d according to the changing state of the network interfaces. All scripts in this directory are invoked for every state change of any network interface; the scripts must decide whether to process the event.

The companion service NetworkManager must be running to generate the network status change events to which NetworkManagerDispatcher responds.

Service Control

To obtain the NetworkManagerDispatcher service, install the NetworkManager RPM package:

# yum install NetworkManager

To manage the NetworkManagerDispatcher service on subsequent shutdowns and reboots, use the chkconfig tool:

# chkconfig NetworkManager on
# chkconfig NetworkManagerDispatcher on
# service NetworkManager start
Setting network parameters...
Starting dhcdbd:                                           [  OK  ]
Starting NetworkManager daemon:                            [  OK  ]
# service NetworkManagerDispatcher start
Starting NetworkManagerDispatcher daemon:                  [  OK  ]
# chkconfig --list NetworkManager
NetworkManager  0:off   1:off   2:off   3:on    4:on    5:on    6:off
# chkconfig --list NetworkManagerDispatcher
NetworkManagerDispatcher 0:off   1:off   2:off   3:on    4:on    5:on    6:off

To control the NetworkManagerDispatcher service immediately, use the service tool:

# service NetworkManagerDispatcher
Usage: /etc/init.d/NetworkManagerDispatcher {start|stop|restart|reload|status}

Start this daemon:

# service NetworkManagerDispatcher start
Starting NetworkManagerDispatcher daemon:                  [  OK  ]

Stop this daemon:

# service NetworkManagerDispatcher stop
Stopping NetworkManagerDispatcher daemon:                  [  OK  ]

Configuration

Below is a sample script provided with the NetworkManager package located in the /etc/NetworkManager/dispatcher.d directory.

# cat /etc/NetworkManager/dispatcher.d/00-netreport
#!/bin/sh

cd /etc/sysconfig/network-scripts
. ./network-functions

[ -f ../network ] && . ../network

# Notify programs that have requested notification
do_netreport

exit 0
[root@NVMBD1S12BKPMED15 dispatcher.d]# cat 20-chrony
#!/bin/sh
# This is a NetworkManager dispatcher script for chronyd to set its NTP sources
# online/offline when a default route is configured/removed on the system.

export LC_ALL=C

if [ "$2" = "up" ]; then
        /sbin/ip route list dev "$1" | grep -q '^default' &&
                /usr/bin/chronyc online > /dev/null 2>&1
fi

if [ "$2" = "down" ]; then
        /sbin/ip route list | grep -q '^default' ||
                /usr/bin/chronyc offline > /dev/null 2>&1
fi

exit 0

Notes

The NetworkManager facility was designed to facilitate mobile network users, such as laptop users, as they move from one wireless hot-spot to another. System administrators should carefully consider whether to enable the NetworkManager facility on servers connected to a fixed network.

Related Post