Linux Network Manager

NetworkManager

NetworkManage attempts to keep an active network connection available at all times.
NetworkManager is composed of two layers:
  • A daemon running as root: network-manager.
  • A front-end: nmcli and nmtui (enclosed in package network-manager)
NetworkManager will only handle interfaces not declared in /etc/network/interfaces.
NetworkManager keeps connection information on known individual networks in configuration files called profiles, sometimes referred to as connections only.
Profiles are stored at /etc/NetworkManager/system-connections/.

The options used in the profile can be found in the manpage on nm-settings:


man nm-settings  
  

How it works

The NetworkManager daemon runs as a privileged service (since it must access and control hardware), but provides a D-Bus interface on the system bus to allow for fine-grained control of networking.

To store pre-defined network connections, two separate services, the "system settings service" and the "user settings service" store connection information and provide these to NetworkManager, also via D-Bus.

nmcli

The nmcli (NetworkManager Command Line Interface) command-line utility can be utilized as a replacement for nm-applet or other graphical clients.
The basic format of a nmcli command is as follows:

nmcli [OPTIONS] OBJECT { COMMAND | help } [ARGUMENTS...]
where OBJECT can be one of the following options:
  • general
  • networking
  • radio
  • connection
  • device
  • agent
  • monitor

COMMAND

General Commands


nmcli general { status | hostname | permissions | logging } [ARGUMENTS...]
  • status
  • Show overall status of NetworkManager.
    This is the default action, when no additional command is provided for nmcli general.
  • hostname [hostname]
  • Get and change system hostname.
    With no arguments, this prints currently configured hostname.
    When you pass a hostname, it will be handed over to NetworkManager to be set as a new system hostname. The hostname is stored in /etc/hostname file in most distributions.
  • permissions
  • Show the permissions a caller has for various authenticated operations that NetworkManager provides, like enable and disable networking, changing Wi-Fi and WWAN state, modifying connections, etc.
  • logging [level level] [domains domains...]
  • Get and change NetworkManager logging level and domains.
    Without any argument current logging level and domains are shown.
    In order to change logging state, provide level and, or, domain parameters. See NetworkManager.conf(5) for available level and domain values.

Networking Control Commands


nmcli networking { on | off | connectivity } [ARGUMENTS...]
  • on, off
  • Enable or disable networking control by NetworkManager.
    All interfaces managed by NetworkManager are deactivated when networking is disabled.
  • connectivity [check]
  • Get network connectivity state.
    The optional check argument tells NetworkManager to re-check the connectivity, else the most recent known connectivity state is displayed without re-checking.
    Possible states are:
    • none
    • the host is not connected to any network.
    • portal
    • the host is behind a captive portal and cannot reach the full Internet.
    • limited
    • the host is connected to a network, but it has no access to the Internet.
    • full
    • the host is connected to a network and has full access to the Internet.
    • unknown
    • the connectivity status cannot be found out.

    Radio Transmission Control Commands

    
    nmcli radio { all | wifi | wwan } [ARGUMENTS...]
    
    Show radio switches status, or enable and disable the switches.
    • wifi [ on | off ]
    • Show or set status of Wi-Fi in NetworkManager.
      If no arguments are supplied, Wi-Fi status is printed;
      • on
      • enables Wi-Fi
      • off
      • disables Wi-Fi
    • wwan [ on | off ]
    • Show or set status of WWAN (mobile broadband) in NetworkManager.
      If no arguments are supplied, mobile broadband status is printed;
      • on
      • enables mobile broadband
      • off
      • disables it
    • all [ on | off ]
    • Show or set all previously mentioned radio switches at the same time.

    Examples

    • How to change MTU
    • 
      $ nmcli connection show mymodem | grep mtu
      gsm.mtu:                                auto
      
      $ ifconfig mhi_mbim0
      mhi_mbim0: flags=209<UP,POINTOPOINT,RUNNING,NOARP>  mtu 1500
              inet 10.108.8.23  netmask 255.255.255.240  destination 10.108.8.23
              unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
              RX packets 0  bytes 0 (0.0 B)
              RX errors 0  dropped 0  overruns 0  frame 0
              TX packets 40  bytes 3520 (3.5 KB)
              TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
      
      $ sudo nmcli connection modify mymodem gsm.mtu 1430
      $ nmcli connection show mymodem | grep mtu
      gsm.mtu:                                1430
      
      
      $ sudo systemctl restart NetworkManager
      $ nmcli connection show mymodem | grep mtu
      gsm.mtu:                                1430
      $ ifconfig mhi_mbim0
      mhi_mbim0: flags=209<UP,POINTOPOINT,RUNNING,NOARP>  mtu 1430
              inet 10.108.38.107  netmask 255.255.255.248  destination 10.108.38.107
              unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 1000  (UNSPEC)
              RX packets 0  bytes 0 (0.0 B)
              RX errors 0  dropped 0  overruns 0  frame 0
              TX packets 54  bytes 4752 (4.7 KB)
              TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
      		

    INTRODUCTION TO NETWORKMANAGER DEBUGGING

    Setting the NetworkManager log level

    /etc/NetworkManager/conf.d/95-nm-debug.conf:
    
    [logging]
    domains=ALL:DEBUG  
      
    Restart:
    
    $ sudo systemctl restart NetworkManager
    	
    Check th elog:
      
    $ sudo journalctl -u NetworkManager.service
    

    NetworkManager Reference Manual

    I. Manual Pages

    NetworkManager — network management daemon

    NetworkManager.conf — NetworkManager configuration file

    nmcli — command-line tool for controlling NetworkManager

    nmcli-examples — usage examples of nmcli

    nmtui — Text User Interface for controlling NetworkManager

    nm-settings-dbus — Description of settings and properties of NetworkManager connection profiles on the D-Bus API

    nm-settings-nmcli — Description of settings and properties of NetworkManager connection profiles for nmcli

    nm-settings-keyfile — Description of keyfile settings plugin

    nm-settings-ifcfg-rh — Description of ifcfg-rh settings plugin

    nm-online — ask NetworkManager whether the network is connected

    nm-initrd-generator — early boot NetworkManager configuration generator

    nm-cloud-setup — Overview of Automatic Network Configuration in Cloud

    nm-openvswitch — overview of NetworkManager Open vSwitch support

    II. Network Configuration Setting Specification

    connection — General Connection Profile Settings

    6lowpan — 6LoWPAN Settings

    802-1x — IEEE 802.1x Authentication Settings

    adsl — ADSL Settings

    bluetooth — Bluetooth Settings

    bond — Bonding Settings

    bridge — Bridging Settings

    bridge-port — Bridge Port Settings

    cdma — CDMA-based Mobile Broadband Settings

    dcb — Data Center Bridging Settings

    dummy — Dummy Link Settings

    ethtool — Ethtool Ethernet Settings

    generic — Generic Link Settings

    gsm — GSM-based Mobile Broadband Settings

    infiniband — Infiniband Settings

    ipv4 — IPv4 Settings

    ipv6 — IPv6 Settings

    ip-tunnel — IP Tunneling Settings

    macsec — MACSec Settings

    macvlan — MAC VLAN Settings

    match — Match settings

    802-11-olpc-mesh — OLPC Wireless Mesh Settings

    ovs-bridge — OvsBridge Link Settings

    ovs-dpdk — OvsDpdk Link Settings

    ovs-interface — Open vSwitch Interface Settings

    ovs-patch — OvsPatch Link Settings

    ovs-port — OvsPort Link Settings

    ppp — Point-to-Point Protocol Settings

    pppoe — PPP-over-Ethernet Settings

    proxy — WWW Proxy Settings

    serial — Serial Link Settings

    sriov — SR-IOV settings

    tc — Linux Traffic Control Settings

    team — Teaming Settings

    team-port — Team Port Settings

    tun — Tunnel Settings

    user — General User Profile Settings

    vlan — VLAN Settings

    vpn — VPN Settings

    vrf — VRF settings

    vxlan — VXLAN Settings

    wifi-p2p — Wi-Fi P2P Settings

    wimax — WiMax Settings

    802-3-ethernet — Wired Ethernet Settings

    wireguard — WireGuard Settings

    802-11-wireless — Wi-Fi Settings

    Properties:
    • band
    • 802.11 frequency band of the network.
      • "a" for 5GHz 802.11a
      • "bg" for 2.4GHz 802.11
      This will lock associations to the Wi-Fi network to the specific band, i.e. if "a" is specified, the device will not associate with the same network in the 2.4GHz band even if the network's settings are compatible.
      This setting depends on specific driver capability and may not work with all drivers.

    802-11-wireless-security — Wi-Fi Security Settings

    wpan — IEEE 802.15.4 (WPAN) MAC Settings

    hostname — Hostname settings

    ovs-external-ids — OVS External IDs Settings

    veth — Veth Settings

留言

熱門文章