安装nmcli工具

yum install NetworkManager

使用语法

Usage: nmcli [OPTIONS] OBJECT { COMMAND | help }

OBJECT
g[eneral] NetworkManager's general status and operations
n[etworking] overall networking control
r[adio] NetworkManager radio switches
c[onnection] NetworkManager's connections
d[evice] devices managed by NetworkManager
a[gent] NetworkManager secret agent or polkit agent
m[onitor] monitor NetworkManager changes

CONNECTION MANAGEMENT COMMANDS
nmcli connection {show | up | down | modify | add | edit | clone | delete | monitor | reload | load| import | export} [ARGUMENTS...]

show [--active] [id | uuid | path | apath] ID...

id, uuid, path and apath keywords can be used if ID is ambiguous. Optional ID-specifying
keywords are: id
the ID denotes a connection name. uuid
the ID denotes a connection UUID. path
the ID denotes a D-Bus static connection path in the format of
/org/freedesktop/NetworkManager/Settings/num or just num. apath
the ID denotes a D-Bus active connection path in the format of
/org/freedesktop/NetworkManager/ActiveConnection/num or just num. It is possible to filter the output using the global --fields option. Use the following values: profile
only shows static profile configuration. active
only shows active connection data (when the profile is active).

DEVICE MANAGEMENT COMMANDS
nmcli device {status | show | set | connect | reapply | modify | disconnect | delete | monitor |wifi | lldp} [ARGUMENTS...]

 Show and manage network interfaces.

       status
Print status of devices. This is the default action if no command is specified to nmcli device. show [ifname]
Show detailed information about devices. Without an argument, all devices are examined. To get
information for a specific device, the interface name has to be provided. set [ifname] ifname [autoconnect {yes | no}] [managed {yes | no}]
Set device properties. connect ifname
Connect the device. NetworkManager will try to find a suitable connection that will be
activated. It will also consider connections that are not set to auto connect. If --wait option is not specified, the default timeout will be seconds. reapply ifname
Attempt to update device with changes to the currently active connection made since it was last
applied. modify ifname {option value | [+|-]setting.property value}...
Modify the settings currently active on the device. This command lets you do temporary changes to a configuration active on a particular device.
The changes are not preserved in the connection profile. See nm-settings() for the list of available properties. Please note that some properties can't
be changed on an already connected device. You can also use the aliases described in PROPERTY ALIASES section. The syntax is the same as
of the nmcli connection modify command. disconnect ifname...
Disconnect a device and prevent the device from automatically activating further connections
without user/manual intervention. Note that disconnecting software devices may mean that the
devices will disappear. If --wait option is not specified, the default timeout will be seconds. delete ifname...
Delete a device. The command removes the interface from the system. Note that this only works
for software devices like bonds, bridges, teams, etc. Hardware devices (like Ethernet) cannot
be deleted by the command. If --wait option is not specified, the default timeout will be seconds. monitor [ifname...]
Monitor device activity. This command prints a line whenever the specified devices change
state. Monitors all devices in case no interface is specified. The monitor terminates when all
specified devices disappear. If you want to monitor device addition consider using the global
monitor with nmcli monitor command. wifi [list [ifname ifname] [bssid BSSID]]
List available Wi-Fi access points. The ifname and bssid options can be used to list APs for a
particular interface or with a specific BSSID, respectively.

范例

 This section presents various examples of nmcli usage. If you want even more, please refer to
nmcli-examples() manual page. nmcli -t -f RUNNING general
tells you whether NetworkManager is running or not. nmcli -t -f STATE general
shows the overall status of NetworkManager. nmcli radio wifi off
switches Wi-Fi off. nmcli connection show
lists all connections NetworkManager has. nmcli -p -m multiline -f all con show
shows all configured connections in multi-line mode. nmcli connection show --active
lists all currently active connections. nmcli -f name,autoconnect c s
shows all connection profile names and their auto-connect property. nmcli -p connection show "My default em1"
shows details for "My default em1" connection profile. nmcli --show-secrets connection show "My Home WiFi"
shows details for "My Home WiFi" connection profile with all passwords. Without --show-secrets
option, secrets would not be displayed. nmcli -f active connection show "My default em1"
shows details for "My default em1" active connection, like IP, DHCP information, etc. nmcli -f profile con s "My wired connection"
shows static configuration details of the connection profile with "My wired connection" name. nmcli -p con up "My wired connection" ifname eth0
activates the connection profile with name "My wired connection" on interface eth0. The -p
option makes nmcli show progress of the activation. nmcli con up 6b028a27-6dc9---e9ad1dd43761 ap :3A::7C::D3
connects the Wi-Fi connection with UUID 6b028a27-6dc9---e9ad1dd43761 to the AP with
BSSID :3A::7C::D3. nmcli device status
shows the status for all devices. nmcli dev disconnect em2
disconnects a connection on interface em2 and marks the device as unavailable for
auto-connecting. As a result, no connection will automatically be activated on the device until
the device's 'autoconnect' is set to TRUE or the user manually activates a connection. nmcli -f GENERAL,WIFI-PROPERTIES dev show wlan0
shows details for wlan0 interface; only GENERAL and WIFI-PROPERTIES sections will be shown. nmcli -f CONNECTIONS device show wlp3s0
shows all available connection profiles for your Wi-Fi interface wlp3s0. nmcli dev wifi
lists available Wi-Fi access points known to NetworkManager. nmcli dev wifi con "Cafe Hotspot 1" password caffeine name "My cafe"
creates a new connection named "My cafe" and then connects it to "Cafe Hotspot 1" SSID using
password "caffeine". This is mainly useful when connecting to "Cafe Hotspot 1" for the first
time. Next time, it is better to use nmcli con up id "My cafe" so that the existing connection
profile can be used and no additional is created. nmcli -s dev wifi hotspot con-name QuickHotspot
creates a hotspot profile and connects it. Prints the hotspot password the user should use to
connect to the hotspot from other devices. nmcli dev modify em1 ipv4.method shared
starts IPv4 connection sharing using em1 device. The sharing will be active until the device is
disconnected. nmcli dev modify em1 ipv6.address :db8::a:bad:c0de
temporarily adds an IP address to a device. The address will be removed when the same
connection is activated again. nmcli connection add type ethernet autoconnect no ifname eth0
non-interactively adds an Ethernet connection tied to eth0 interface with automatic IP
configuration (DHCP), and disables the connection's autoconnect flag. nmcli c a ifname Maxipes-fik type vlan dev eth0 id
non-interactively adds a VLAN connection with ID . The connection will use eth0 and the VLAN
interface will be named Maxipes-fik. nmcli c a ifname eth0 type ethernet ipv4.method disabled ipv6.method link-local
non-interactively adds a connection that will use eth0 Ethernet interface and only have an IPv6
link-local address configured. nmcli connection edit ethernet-em1-
edits existing "ethernet-em1-2" connection in the interactive editor. nmcli connection edit type ethernet con-name "yet another Ethernet connection"
adds a new Ethernet connection in the interactive editor. nmcli con mod ethernet- connection.autoconnect no
modifies 'autoconnect' property in the 'connection' setting of 'ethernet-2' connection. nmcli con mod "Home Wi-Fi" wifi.mtu
modifies 'mtu' property in the 'wifi' setting of 'Home Wi-Fi' connection. nmcli con mod em1- ipv4.method manual ipv4.addr "192.168.1.23/24 192.168.1.1, 10.10.1.5/8,
10.0.0.11"
sets manual addressing and the addresses in em1- profile. nmcli con modify ABC +ipv4.dns 8.8.8.8
appends a Google public DNS server to DNS servers in ABC profile. nmcli con modify ABC -ipv4.addresses "192.168.100.25/24 192.168.1.1"
removes the specified IP address from (static) profile ABC. nmcli con import type openvpn file ~/Downloads/frootvpn.ovpn
imports an OpenVPN configuration to NetworkManager. nmcli con export corp-vpnc /home/joe/corpvpn.conf
exports NetworkManager VPN profile corp-vpnc as standard Cisco (vpnc) configuration.

1、看看使用中的con名称

nmcli con show

2、修改IP:nmcli con mod eth0 ipv6.addresses fec0:fec0:fe19:2192::49:20/64

3、激活配置:nmcli con up eth0

4、验证运行生效 nmcli、ifconfig、ip a

5、验证已经写入配置文件 less /etc/sysconfig/network-scripts/ifcfg-eth0

nmcli 使用记录---fatt的更多相关文章

  1. CentOS 7使用nmcli配置双网卡聚合

    进入CentOS 7以后,网络方面变化比较大,例如eth0不见了,ifconfig不见了,其原因是网络服务全部都由NetworkManager管理了,下面记录下今天下午用nmcli配置的网卡聚合,网络 ...

  2. nmcli工具详解

    目录 1. nmcli 安装 2. nmcli 基本选项 3. general 常规选项 3.1 status 3.2 hostname 3.3 permissions 3.4 loggin 4. n ...

  3. yum provides "*/nmcli" and apt-get

    一般来说著名的linux系统基本上分两大类: 1.RedHat系列:Redhat.Centos.Fedora等 2.Debian系列:Debian.Ubuntu等 RedHat 系列 1 常见的安装包 ...

  4. 转:CentOS 7使用nmcli配置双网卡聚合LACP

    进入CentOS 7以后,网络方面变化比较大,例如eth0不见了,ifconfig不见了,其原因是网络服务全部都由NetworkManager管理了,下面记录下今天下午用nmcli配置的网卡聚合,网络 ...

  5. 红帽学习记录[RHCE] 防火墙与网络合作

    目录 防火墙 基本介绍 firewalld 区域zone 管理firewalld 关于富规则 定义 firewalld操作富规则的命令 语法 常用的示例 网络合作 链路聚合 网络组的文件 网络组命令 ...

  6. nmcli详解

    1. nmcli 安装 [root@liujunjun ~]# yum install -y NetworkManager CentOS7默认已安装了 2. nmcli 基本选项 选项 作用 -t 简 ...

  7. RHCE实验记录总结-2-RHCE

    RHCSA实验总结-点击跳转 RHCE实验 RHCE这边我简单分了下类: ## 网络与安全 1. IPv6 设置(推荐使用GUI程序 nm-connection-editor来完成) 2. team ...

  8. [转帖]LINUX网络配置---nmtui&nmcli

    LINUX网络配置---nmtui&nmcli https://blog.51cto.com/13625527/2151853?source=dra 两年前曾经打打印过 几页命令 里面就有 n ...

  9. nmcli的基本使用

    介绍NetworkManager.centos8.nmcli CentOS 7中同时支持network.service和NetworkManager.service(简称NM)2种方式配置网络,而在C ...

随机推荐

  1. Selenium-Grid2 配置RemoteWebDriver

    为什么要使用Selenium Grid ? 分布式运行大规模的Test 能够通过一个中央点,很容易的运行不同OS上的不同browser 最小化对Grid的维护时间,并能充分利用虚拟设备 Seleniu ...

  2. zookeeper和淘宝dubbo的关系

    Dubbo建议使用Zookeeper作为服务的注册中心. 1.   Zookeeper的作用:         zookeeper用来注册服务和进行负载均衡,哪一个服务由哪一个机器来提供必需让调用者知 ...

  3. tomcat结合nginx或apache做负载均衡及session绑定

    1.tomcat结合nginx做负载均衡,session绑定 nginx:192.168.223.136   tomcat:192.168.223.146:8081,192.168.223.146:8 ...

  4. Java学习第三周摘要

    20145307<Java程序设计>第三周学习总结 教材学习内容总结 认识对象 类类型 Java可区分为基本类型和类类型两大类型系统,其中类类型也称为参考类型.sun就是一个类类型变量,类 ...

  5. RocEDU.阅读.写作《霍乱时期的爱情》书摘(一)

    不可避免,苦杏仁的香味总是让他想起爱情受阻后的命运. 一切都显得凄凉无助,可那一间间肮脏的小酒馆里却传来震耳欲聋的鼓乐声,那是穷人的狂欢,既无涉上帝,也无涉圣神降临节的诫命. 他们经常谈起它,一同承受 ...

  6. 20145321 《Java程序设计》课程总结

    20145321 <Java程序设计>课程总结 读书笔记链接汇总 第一周读书笔记 第二周读书笔记 第三周读书笔记 第四周读书笔记 第五周读书笔记 第六周读书笔记 第七周读书笔记 第八周读书 ...

  7. Socket 是嘛玩意儿(简单聊聊)

    网络上的两个程序通过一个双向的通信连接实现数据的交换,这个连接的一端称为一个socket. 建立网络通信连接至少要一对端口号(socket).socket本质是编程接口(API),对TCP/IP的封装 ...

  8. React Native区分安卓/iOS平台

    import { Platform, } from 'react-native'; alert(JSON.stringify(Platform)): android手机弹出:{"OS&quo ...

  9. [BZOJ1584]Cleaning Up 打扫卫生

    Description 有N头奶牛,每头那牛都有一个标号Pi,1 <= Pi <= M <= N <= 40000.现在Farmer John要把这些奶牛分成若干段,定义每段的 ...

  10. Linux系统CentOS使用yum方式安装指定版本的PHP 添加yum源 从PHP5.3升级到5.4/5.5/5.6

    默认的版本太低了,手动安装有一些麻烦,想采用Yum安装的可以使用下面的方案: 首先删除旧版本的PHP, 通过yum list installed | grep php可以查看所有已安装的php软件 使 ...