1.nmcli
[root@cloud ~]# nmcli --help
Usage: nmcli [OPTIONS] OBJECT { COMMAND | help }
OPTIONS
-o[verview] overview mode (hide default values)
-t[erse] terse output
-p[retty] pretty output
-m[ode] tabular|multiline output mode
-c[olors] auto|yes|no whether to use colors in output
-f[ields] <field1,field2,...>|all|common specify fields to output
-g[et-values] <field1,field2,...>|all|common shortcut for -m tabular -t -f
-e[scape] yes|no escape columns separators in values
-a[sk] ask for missing parameters
-s[how-secrets] allow displaying passwords
-w[ait] <seconds> set timeout waiting for finishing operations
-v[ersion] show program version
-h[elp] print this 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
2.nmcli c -h
[root@cloud ~]# nmcli c -h
Usage: nmcli connection { COMMAND | help }
COMMAND := { show | up | down | add | modify | clone | edit | delete | monitor | reload | load | import | export }
show [--active] [--order <order spec>]
show [--active] [id | uuid | path | apath] <ID> ...
up [[id | uuid | path] <ID>] [ifname <ifname>] [ap <BSSID>] [passwd-file <file with passwords>]
down [id | uuid | path | apath] <ID> ...
add COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS SLAVE_OPTIONS IP_OPTIONS [-- ([+|-]<setting>.<property> <value>)+]
modify [--temporary] [id | uuid | path] <ID> ([+|-]<setting>.<property> <value>)+
clone [--temporary] [id | uuid | path ] <ID> <new name>
edit [id | uuid | path] <ID>
edit [type <new_con_type>] [con-name <new_con_name>]
delete [id | uuid | path] <ID>
monitor [id | uuid | path] <ID> ...
reload
load <filename> [ <filename>... ]
import [--temporary] type <type> file <file to import>
export [id | uuid | path] <ID> [<output file>]
3.nmcli c mod -h
[root@cloud ~]# nmcli c mod -h
Usage: nmcli connection modify { ARGUMENTS | help }
ARGUMENTS := [id | uuid | path] <ID> ([+|-]<setting>.<property> <value>)+
Modify one or more properties of the connection profile.
The profile is identified by its name, UUID or D-Bus path. For multi-valued
properties you can use optional '+' or '-' prefix to the property name.
The '+' sign allows appending items instead of overwriting the whole value.
The '-' sign allows removing selected items instead of the whole value.
Examples:
nmcli con mod home-wifi wifi.ssid rakosnicek
nmcli con mod em1-1 ipv4.method manual ipv4.addr "192.168.1.2/24, 10.10.1.5/8"
nmcli con mod em1-1 +ipv4.dns 8.8.4.4
nmcli con mod em1-1 -ipv4.dns 1
nmcli con mod em1-1 -ipv6.addr "abbe::cafe/56"
nmcli con mod bond0 +bond.options mii=500
nmcli con mod bond0 -bond.options downdelay
4.示例(添加网卡及参数)
[root@cloud ~]# nmcli c add con-name ens160 type ethernet autoconnect yes ifname ens160 ip4 10.1.1.170/24 ipv4.dns "210.21.196.6 202.96.128.86" gw4 10.1.1.254