惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Last Watchdog
The Last Watchdog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
Y
Y Combinator Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
博客园_首页
小众软件
小众软件
I
InfoQ
J
Java Code Geeks
月光博客
月光博客
S
Secure Thoughts
Microsoft Security Blog
Microsoft Security Blog
V
Visual Studio Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Stack Overflow Blog
Stack Overflow Blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
N
News and Events Feed by Topic
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
The Cloudflare Blog
T
Threat Research - Cisco Blogs
A
About on SuperTechFans
H
Help Net Security
MongoDB | Blog
MongoDB | Blog
博客园 - 聂微东
人人都是产品经理
人人都是产品经理
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Latest news
Latest news
G
GRAHAM CLULEY
IT之家
IT之家
C
Cisco Blogs
Last Week in AI
Last Week in AI
Engineering at Meta
Engineering at Meta
L
LangChain Blog
The Register - Security
The Register - Security
SecWiki News
SecWiki News
M
MIT News - Artificial intelligence
NISL@THU
NISL@THU
T
Tenable Blog
博客园 - Franky
美团技术团队
I
Intezer
U
Unit 42
雷峰网
雷峰网
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
SegmentFault 最新的问题
C
Cyber Attacks, Cyber Crime and Cyber Security

又见苍岚

COLMAP PatchMatch Stereo 算法详解 事件驱动的状态机框架:从理论到工程实践 Git 在国内网络环境下无法 Push 的排查与修复 —— 配置 Clash 代理 分段五次多项式插值原理详解 路径插值方法深度对比研究 Claude Code 使用指南 OpenClaw 记忆管理与技能创建指南 CBS(Conflict-Based Search)算法详解 A* 算法及其变种详解 OpenClaw 配置多 Agents Windows Powershell 无法加载文件,因为在此系统上禁止运行脚本问题的解决方案 MaxClaw 安装流程 大模型 AI 名词介绍 AList 网盘聚合工具简介 Protobuf 简介与测试 Claude Code 简介以及 GLM 4.7 模型接入 Github 歌词下载工具 163MusicLyrics Python __getattr__ 懒加载 Python TypedDict 机器人仿真平台 Gazebo 安装记录 机器人仿真平台 Gazebo 简介 多机器人路径规划问题(Multi-Agent Path Finding, MAPF)简介 Python exifread 读取修改过的 jpeg 信息错误问题修复 3D 坐标系变换的理解 3D 旋转矩阵基本概念 MongoDB Compass 介绍 Python 环境管理工具 uv Flutter 开发指南 Snipaste 安装下载与黑屏问题解决方案 全局路径规划算法记录 2025 Python 版本性能测试 Flutter Hello World Flutter 安装环境配置 Ubuntu VMware 硬盘扩容后 SMBus Host controller not enabled 报错问题解决 Python NetworkX 教程 Docker GPU 报错 - Failed to initialize NVML Unknown Error 解决方案 Python matplotlib 图表绘制 cuda-toolkit 安装替代 Cuda 与 Cudnn Jinja2 Python 利用 docxtpl 和 Jinja2 生成基于模板的 Word 文档 Docker 实现 CPU 核心隔离 LoFTR 基于 Transformer 的特征提取匹配算法 OmniGlue 特征匹配 SuperGlue 使用图神经网络学习特征匹配 Ubuntu 下将 xlsx 文件按照 sheet 转换为 图片 Python 使用 SQLAlchemy Python FastAPI 教程 openwrt 软路由配置安装 Nav2 地图文件(PGM/YAML)规范标准 3D OBJ 模型转换为 glb 瓦片格式 Python 源码 Redis 数据库介绍 Ubuntu 22.04 内核自动升级导致 MongoDB 7.0.12 错误记录 ubuntu 20.04 安装 ROS Noetic ubuntu 18.04 安装 ROS Melodic VMware Workstation Pro 个人免费版下载、安装、使用指南 Hybrid A-star 路径规划 Reeds-Shepp 曲线 Dubins 曲线 Linux kvm 虚拟机网络不通的问题解决方法 Ubuntu 自动内存清理 BiliBili 缓存视频转 mp4 Python 求解线性规划 3D Gaussian Splatting 官方源码实践记录 ImageMagick 教程 Ubuntu 22.04 安装 Colmap 对数几率 odds SuperPoint 自监督深度学习特征点提取 SyncTV Music Tag Web 在线音乐信息整理工具 ncm 格式转 mp3 MusicBrainz 音乐元数据百科数据库 Ubuntu 网络流量监控工具 私人云音乐平台 Navidrome 入门 手眼标定 四元数(Quaternions) OHTTPS 实现免费自动 https 证书申请、更新、部署 ubuntu 22.04 安装 CloudCompare 单机 KVM 虚拟机冷迁移 Ubuntu 22.04 使用 mdadm 实现软 raid 小鱼 一键安装 ROS-humble Fluid -46- 基于 Simpletex API 构建公式识别页面 公式识别 API 简介 -- Simpletex 使用 Python web 部署库 waitress 3D Gaussian Splatting for Real-Time Radiance Field Rendering Ubuntu Swap 简介与空间扩展 Ubuntu 24.04 安装 forticlient Clash Verge 使用 MongoDB 7.0.17 集群 Docker 构建源码 Error code - 2013. Lost connection to MySQL server during query 问题解决 Python 日志记录库 loguru 使用指北 Python 实现 Web 日志查看服务 MySQL LOAD DATA LOCAL INFILE 极速数据加载 Image size exceeds limit of 89478485 pixels 解决方案 Docker 使用 NVIDIA GPU 驱动错误解决 阿里云 docker 镜像仓库 Ubuntu中没有wired connected的解决方案 MinIO 简介 subconverter 代理订阅格式转换 修复 node –openssl-legacy-provider is not allowed in NODE_OPTIONS 错误 Ubuntu 使用 Clash For Linux 客户端
Ubuntu nmcli 网络管理工具使用指南
Yiwei Zhang · 2025-06-05 · via 又见苍岚

nmcli 是 NetworkManager 的命令行工具,用于管理 Linux 系统的网络连接, 纯命令行执行,本文记录使用方法。

简介

nmcli 是 NetworkManager 的命令行工具,用于管理 Linux 系统的网络连接。它提供了一种配置、监控和排除网络连接故障的全面方法,支持管理有线、无线、VPN、VLAN 等多种网络类型

安装

nmcli ubuntu 系统默认自带,可以通过命令确认版本

1
nmcli -v

如果没有找到命令可以手动安装。

  • 安装 NetworkManager
1
2
sudo apt update
sudo apt install network-manager network-manager-gnome
  • 启动服务
1
2
sudo systemctl start NetworkManager
sudo systemctl enable NetworkManager

常用命令与示例

查看网络状态

命令 功能 示例
nmcli 显示网络设备状态 nmcli
nmcli device status 查看设备状态 nmcli device status
nmcli connection show 显示所有连接 nmcli connection show
nmcli connection show <network> 显示 network 链接信息 nmcli connection show wlo1

有线网络配置

  • 静态IP配置
1
2
3
bashCopy Codesudo nmcli connection add type ethernet con-name "my-eth" ifname eth0 ip4 192.168.1.100/24 gw4 192.168.1.1
sudo nmcli connection modify "my-eth" ipv4.dns "8.8.8.8 8.8.4.4"
sudo nmcli connection up "my-eth"
  • ‌修改静态 IP 和网关‌:
1
2
3
4
sudo nmcli connection modify "有线连接1" \
ipv4.addresses 192.168.1.100/24 \
ipv4.gateway 192.168.1.1 \
ipv4.method manual
  • 设置 DNS‌
1
2
sudo nmcli connection modify "有线连接1" \
ipv4.dns "8.8.8.8 8.8.4.4"
  • DHCP配置
1
2
bashCopy Codesudo nmcli connection add type ethernet con-name "dhcp-eth" ifname eth0
sudo nmcli connection up "dhcp-eth"
  • 激活配置‌:
1
2
sudo nmcli connection down "有线连接1" && \
sudo nmcli connection up "有线连接1" # 重启连接生效

无线网络配置

  • 扫描WiFi
1
nmcli device wifi list
  • 连接WiFi
1
nmcli device wifi connect "SSID名称" password "密码"
  • 创建热点
1
sudo nmcli device wifi hotspot ifname wlan0 con-name my-hotspot ssid MyHotspot password mypassword

高级网络配置

  • 创建网桥
1
2
3
bashCopy Codesudo nmcli connection add type bridge ifname br0
sudo nmcli connection add type bridge-slave ifname eth0 master br0
sudo nmcli connection up br0
  • VLAN配置
1
2
3
bashCopy Codesudo nmcli connection add type vlan con-name vlan10 ifname eth0.10 dev eth0 id 10
sudo nmcli connection modify vlan10 ipv4.addresses 192.168.10.1/24
sudo nmcli connection up vlan10

连接管理

命令 功能 示例
nmcli connection up 激活连接 nmcli connection up eth0
nmcli connection down 停用连接 nmcli connection down eth0
nmcli connection delete 删除连接 nmcli connection delete eth068

故障排除

查看详细连接信息

1
nmcli connection show "连接名称"

检查NetworkManager日志

1
journalctl -u NetworkManager -f

重置网络配置

1
2
bashCopy Codesudo nmcli networking off
sudo nmcli networking on

实用技巧

  1. 简洁输出‌:使用-t参数获得简洁格式输出

    1
    nmcli -t device
  2. 字段过滤‌:使用-f参数指定显示字段

    1
    nmcli -f DEVICE,TYPE device
  3. 修改现有连接‌:

    1
    nmcli connection modify "连接名" ipv4.method manual ipv4.addresses 192.168.1.100/24
  4. 多IP地址配置‌:

    1
    nmcli connection modify eth0 +ipv4.addresses 10.0.0.1/24

文章链接:
https://www.zywvvd.com/notes/system/linux/nmcli/nmcli/