「NetworkManager」- 网络的配置及管理工具 | Linux | NETWORK-MANAGER

认识

官网:https://networkmanager.dev/
文档:https://networkmanager.dev/docs/
仓库:https://gitlab.freedesktop.org/NetworkManager/NetworkManager

NetworkManager is the standard Linux network configuration tool suite. It supports large range of networking setups, from desktop to servers and mobile and integrates well with popular desktop environments and server configuration management tools. 简而言之,NetworkManager 是标准的 Linux 网络配置工具集,其支持从 Desktop 到 Server 和 Mobile Device 的各种网络设置,并与流行的桌面环境和服务器配置管理工具很好地集成。

组成

原理概述

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/main/README.md?ref_type=heads

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.

NetworkManager does not store connections or settings, it is only the mechanism by which those connections are selected and activated.

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.

Each settings service can determine how and where it persistently stores the connection information; for example, the GNOME applet stores its configuration in GConf, and the system settings service stores its config in distro-specific formats, or in a distroagnostic format, depending on user/administrator preference.

A variety of other system services are used by NetworkManager to provide network functionality: wpa_supplicant for wireless connections and 802.1x wired connections, pppd for PPP and mobile broadband connections, DHCP clients for dynamic IP addressing, dnsmasq for proxy nameserver and DHCP server functionality for internet connection sharing, and avahi-autoipd for IPv4 link-local addresses. Most communication with these daemons occurs, again, via D-Bus.

程序文件

nmcli,is a command-line tool for controlling NetworkManager and getting its status.
nm-online,is a utility to find out whether you are online.
nmtui,is an interactive ncurses based interface for nmcli.
nmtui-connect,is an interactive ncurses based interface connection to activate/deactivate connections.
nmtui-edit,is an interactive ncurses based interface connection editor.
nmtui-hostname,is an interactive ncurses based interface hostname editor.
NetworkManager,is the network management daemon.

性质

  • 自动网络连接:NetworkManager 能够自动地检测和连接到可用的有线和无线网络。
  • 易于使用:它提供了一个图形用户界面(GUI),用户可以通过这个界面来查看可用的网络和连接状态,也可以在这个界面上进行网络设置的更改。
  • 宽泛的支持:其支持各种网络协议,例如,有线网络、无线网络、移动宽带、VPN、DSL、……
  • 网络配置:用户可以创建、编辑、保存和删除各种类型的网络配置,包括 IP 地址、DNS,以及其他网络设置。
  • 脚本支持:其提供了命令行接口 (CLI),使得用户可以通过脚本或者命令行进行网络配置。
  • 状态通知:其会在网络连接状态发生更改时提供系统通知。
  • 系统集成:其能够和多个系统和应用程序集成,例如 Network Security Services (NSS),系统的 DNS 解析服务,以及其他的网络相关服务和应用。

构建

—— 安装 | 升级 | 实例化 | …

源码编译

BLFS / NetworkManager-1.4.0 / http://www.linuxfromscratch.org/blfs/view/7.10/basicnet/networkmanager.html

Ubuntu 18.04 TLS

安装 NetworkManager 服务:

apt-get install network-manager
apt-get install network-manager-*                                               # 安装全家桶

systemctl start NetworkManager.service
systemctl enable NetworkManager.service

如果 NetwrokManager 无法管理网络接口,可能需要进行如下处理:

  • 修改 /etc/network/interfaces 文件,注释全部与接口配置有关的行(例如,除 lo 接口、……)

应用

—— 该笔记将记录:在 Linux 中,如何使用 NetworkManager 管理网络(偏向与服务器网络设置,而非桌面环境),以及常见问题处理;

NetworkManager Reference Manual – GNOME Developer Center

How do I prevent Network Manager from controlling an interface?
Disable network manager for a particular interface
Ignore interface in NetworkManager

改进

WIP

参考

NetworkManager – Community Help Wiki