NetworkManager Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
* https://people.freedesktop.org/~lkundrak/nm-docs/NetworkManager.html
=Internal=
=Internal=


Line 14: Line 18:


In a systemd driven system, NetworkManager pulls the <tt>[[Linux systemd and Network Status#network_target |network.target]]</tt>.
In a systemd driven system, NetworkManager pulls the <tt>[[Linux systemd and Network Status#network_target |network.target]]</tt>.
=Dispatcher Scripts=
NetworkManager will execute scripts in the /etc/NetworkManager/dispatcher.d directory or subdirectories in alphabetical order in response to network events. Each script should be a regular executable file owned by root, must not be writable by group or other, and not setuid. Each script receives two arguments, the first being the interface name of the device an operation just happened on, and second the action:
* '''pre-up''' - the interface is connected to the network but is not yet fully activated. Scripts acting on this event must be placed or symlinked into the /etc/NetworkManager/dispatcher.d/pre-up.d directory, and NetworkManager will wait for script execution to complete before indicating to applications that the interface is fully activated.
* '''up''' - the interface has been activated.
* '''pre-down''' - the interface will be deactivated but has not yet been disconnected from the network. Scripts acting on this event must be placed or symlinked into the /etc/NetworkManager/dispatcher.d/pre-down.d directory, and NetworkManager will wait for script execution to complete before disconnecting the interface from its network. Note that this event is not emitted for forced disconnections, like when carrier is lost or a wireless signal fades. It is only emitted when there is an opportunity to cleanly handle a network disconnection event.
* '''down''' - the interface has been deactivated.
* '''vpn-pre-up''' - the VPN is connected to the network but is not yet fully activated. Scripts acting on this event must be placed or symlinked into the /etc/NetworkManager/dispatcher.d/pre-up.d directory, and NetworkManager will wait for script execution to complete before indicating to applications that the VPN is fully activated.
* '''vpn-up''' - a VPN connection has been activated.
* '''vpn-pre-down''' - the VPN will be deactivated but has not yet been disconnected from the network. Scripts acting on this event must be placed or symlinked into the /etc/NetworkManager/dispatcher.d/pre-down.d directory, and NetworkManager will wait for script execution to complete before disconnecting the VPN from its network. Note that this event is not emitted for forced disconnections, like when the VPN terminates unexpectedly or general connectivity is lost. It is only emitted when there is an opportunity to cleanly handle a VPN disconnection event.
* '''vpn-down''' - a VPN connection has been deactivated.
* '''hostname''' - the system hostname has been updated. The interface name (first argument) is empty and no environment variable is set for this action.
* '''dhcp4-change''' - the DHCPv4 lease has changed (renewed, rebound, etc).
* '''dhcp6-change''' - the DHCPv6 lease has changed (renewed, rebound, etc).
The following environment variables will be made available to the dispatcher scripts:
* '''CONNECTION_UUID''' - the UUID of the connection profile.
* '''CONNECTION_ID''' - the name (ID) of the connection profile.
* '''CONNECTION_DBUS_PATH''' - the NetworkManager D-Bus path of the connection.
* '''CONNECTION_FILENAME''' the backing file name of the connection profile (if any).
* '''CONNECTION_EXTERNAL''' - If "1", this indicates that the connection describes a network configuration created outside of NetworkManager.
* '''DEVICE_IFACE''' - the interface name of the control interface of the device. Depending on the device type, this differs from DEVICE_IP_IFACE. For example for ADSL devices, this could be 'atm0' or for WWAN devices it might be 'ttyUSB0'.
* '''DEVICE_IP_IFACE''' - the IP interface name of the device. This is the network interface on which IP addresses and routes will be configured.
* '''IP4_ADDRESS_N''' - the IPv4 address in the format "address/prefix gateway", where N is a number from 0 to (# IPv4 addresses - 1). gateway item in this variable is deprecated, use IP4_GATEWAY instead.
* '''IP4_NUM_ADDRESSES''' - the variable contains the number of IPv4 addresses the script may expect.
* '''IP4_GATEWAY''' - the gateway IPv4 address in traditional numbers-and-dots notation.
* '''IP4_ROUTE_N''' - the IPv4 route in the format "address/prefix next-hop metric", where N is a number from 0 to (# IPv4 routes - 1).
* '''IP4_NUM_ROUTES''' - the variable contains the number of IPv4 routes the script may expect.
* '''IP4_NAMESERVERS''' the variable contains a space-separated list of the DNS servers.
* '''IP4_DOMAINS''' - the variable contains a space-separated list of the search domains.
* '''DHCP4_<dhcp-option-name>''' - if the connection used DHCP for address configuration, the received DHCP configuration is passed in the environment using standard DHCP option names, prefixed with "DHCP4_", like "DHCP4_HOST_NAME=foobar".
* '''IP6_<name> and DHCP6_<name>''' - the same variables as for IPv4 are available for IPv6, but the prefixes are IP6_ and DHCP6_ instead.


=Connection=
=Connection=


=Device=
=Device=

Latest revision as of 16:58, 25 May 2017

External

Internal

Overview

NetworkManager is the default networking service in RHEL 7. It represents a dynamic network control and configuration daemon that attempts to keep network devices and connections up and active when they are available. NetworkManager can configure network aliases, IP addresses, static routes, DNS information and VPN connections. NetworkManager also provides an API via D-Bus which allows applications to query and control network configuration and state.

Theoretically, NetworkManager should coexist with ifcfg scripts.

NetworkManager may overwrite the content of the following:

but it can be configured to not do so. See Configuration for more details.

In a systemd driven system, NetworkManager pulls the network.target.

Dispatcher Scripts

NetworkManager will execute scripts in the /etc/NetworkManager/dispatcher.d directory or subdirectories in alphabetical order in response to network events. Each script should be a regular executable file owned by root, must not be writable by group or other, and not setuid. Each script receives two arguments, the first being the interface name of the device an operation just happened on, and second the action:

  • pre-up - the interface is connected to the network but is not yet fully activated. Scripts acting on this event must be placed or symlinked into the /etc/NetworkManager/dispatcher.d/pre-up.d directory, and NetworkManager will wait for script execution to complete before indicating to applications that the interface is fully activated.
  • up - the interface has been activated.
  • pre-down - the interface will be deactivated but has not yet been disconnected from the network. Scripts acting on this event must be placed or symlinked into the /etc/NetworkManager/dispatcher.d/pre-down.d directory, and NetworkManager will wait for script execution to complete before disconnecting the interface from its network. Note that this event is not emitted for forced disconnections, like when carrier is lost or a wireless signal fades. It is only emitted when there is an opportunity to cleanly handle a network disconnection event.
  • down - the interface has been deactivated.
  • vpn-pre-up - the VPN is connected to the network but is not yet fully activated. Scripts acting on this event must be placed or symlinked into the /etc/NetworkManager/dispatcher.d/pre-up.d directory, and NetworkManager will wait for script execution to complete before indicating to applications that the VPN is fully activated.
  • vpn-up - a VPN connection has been activated.
  • vpn-pre-down - the VPN will be deactivated but has not yet been disconnected from the network. Scripts acting on this event must be placed or symlinked into the /etc/NetworkManager/dispatcher.d/pre-down.d directory, and NetworkManager will wait for script execution to complete before disconnecting the VPN from its network. Note that this event is not emitted for forced disconnections, like when the VPN terminates unexpectedly or general connectivity is lost. It is only emitted when there is an opportunity to cleanly handle a VPN disconnection event.
  • vpn-down - a VPN connection has been deactivated.
  • hostname - the system hostname has been updated. The interface name (first argument) is empty and no environment variable is set for this action.
  • dhcp4-change - the DHCPv4 lease has changed (renewed, rebound, etc).
  • dhcp6-change - the DHCPv6 lease has changed (renewed, rebound, etc).

The following environment variables will be made available to the dispatcher scripts:

  • CONNECTION_UUID - the UUID of the connection profile.
  • CONNECTION_ID - the name (ID) of the connection profile.
  • CONNECTION_DBUS_PATH - the NetworkManager D-Bus path of the connection.
  • CONNECTION_FILENAME the backing file name of the connection profile (if any).
  • CONNECTION_EXTERNAL - If "1", this indicates that the connection describes a network configuration created outside of NetworkManager.
  • DEVICE_IFACE - the interface name of the control interface of the device. Depending on the device type, this differs from DEVICE_IP_IFACE. For example for ADSL devices, this could be 'atm0' or for WWAN devices it might be 'ttyUSB0'.
  • DEVICE_IP_IFACE - the IP interface name of the device. This is the network interface on which IP addresses and routes will be configured.
  • IP4_ADDRESS_N - the IPv4 address in the format "address/prefix gateway", where N is a number from 0 to (# IPv4 addresses - 1). gateway item in this variable is deprecated, use IP4_GATEWAY instead.
  • IP4_NUM_ADDRESSES - the variable contains the number of IPv4 addresses the script may expect.
  • IP4_GATEWAY - the gateway IPv4 address in traditional numbers-and-dots notation.
  • IP4_ROUTE_N - the IPv4 route in the format "address/prefix next-hop metric", where N is a number from 0 to (# IPv4 routes - 1).
  • IP4_NUM_ROUTES - the variable contains the number of IPv4 routes the script may expect.
  • IP4_NAMESERVERS the variable contains a space-separated list of the DNS servers.
  • IP4_DOMAINS - the variable contains a space-separated list of the search domains.
  • DHCP4_<dhcp-option-name> - if the connection used DHCP for address configuration, the received DHCP configuration is passed in the environment using standard DHCP option names, prefixed with "DHCP4_", like "DHCP4_HOST_NAME=foobar".
  • IP6_<name> and DHCP6_<name> - the same variables as for IPv4 are available for IPv6, but the prefixes are IP6_ and DHCP6_ instead.

Connection

Device