CentOS7 使用NetworkManager

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] 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 ]
show [--active] [id | uuid | path | apath] ...

up [[id | uuid | path] ] [ifname ] [ap ] [passwd-file ]

down [id | uuid | path | apath] ...

add COMMON_OPTIONS TYPE_SPECIFIC_OPTIONS SLAVE_OPTIONS IP_OPTIONS [-- ([+|-]. )+]

modify [--temporary] [id | uuid | path] ([+|-]. )+

clone [--temporary] [id | uuid | path ]

edit [id | uuid | path]
edit [type <new_con_type>] [con-name <new_con_name>]

delete [id | uuid | path]

monitor [id | uuid | path] ...

reload

load [ ... ]

import [--temporary] type file

export [id | uuid | path] []

3.nmcli c mod -h

[root@cloud ~]# nmcli c mod -h
Usage: nmcli connection modify { ARGUMENTS | help }

ARGUMENTS := [id | uuid | path] ([+|-]. )+

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

posted on 2019-10-13 23:43  alexzcl  阅读(6379)  评论(0)    收藏  举报

导航