nmcli
简介
nmcli是NetworkManager的命令行工具
在使用nmcli时,NetworkManager必须保持开启
NetworkManager
# 相关命令
systemctl status NetworkManager # 查看运行状态
systemctl start NetworkManager # 启动
systemctl restart NetworkManager # 重启
systemctl stop NetworkManager # 关闭
systemctl is-enabled NetworkManager # 查看是否开机启动
systemctl enable NetworkManager # 开机启动
systemctl disable NetworkManager # 禁止开机启动
nmcli示例
# 显示系统网络状态
nmcli general status
STATE CONNECTIVITY WIFI-HW WIFI WWAN-HW WWAN
已连接 完全 已启用 已启用 已启用 已启用
# 显示主机名
nmcli general hostname
python
# 显示所有网卡连接信息
nmcli connection show
NAME UUID TYPE DEVICE
eth0 0040795d-ed99-4e09-9c88-56927797785b ethernet eth0
# 显示某个网卡详细信息
nmcli connection show eth0
# 配置eth0 静态配置 IP地址 网关 dns 开机自启
nmcli connection modify eth0 ipv4.method manual ipv4.addresses 192.168.150.12/24 ipv4.gateway 192.168.150.1 ipv4.dns 114.114.114.114 connection.autoconnect yes
# 删除网卡
nmcli connection delete eth0
# 添加网卡,ifname对应NAME,con-name对应DEVICE
nmcli connection add con-name eth0 ifname eth0 type ethernet
# 显示所有网络接口设备的状态
nmcli device status
# 启动某个网卡
nmcli connection up eth0
# 断开设备
nmcli connection down eth0
# 创建网桥
nmcli connection add type bridge con-name br0 ifname br0 autoconnect yes
# 查看br0的状态
nmcli device status
# 将我们本地的有线网卡enp8s0连接到br0
nmcli connection add type bridge-slave ifname enp8s0 master br0
# 启动br0
nmcli connection up br0
标签:nmcli,br0,connection,systemctl,NetworkManager,eth0
From: https://www.cnblogs.com/kkit/p/18347261