11.05 怎么设置静态IP

命令帮助

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

OPTIONS

-a, --ask ask for missing parameters

-c, --colors auto|yes|no whether to use colors in output

-e, --escape yes|no escape columns separators in values

-f, --fields <field>|all|common specify fields to output/<field>

-g, --get-values <field>|all|common shortcut for -m tabular -t -f/<field>

-h, --help print this help

-m, --mode tabular|multiline output mode

-o, --overview overview mode

-p, --pretty pretty output

-s, --show-secrets allow displaying passwords

-t, --terse terse output

-v, --version show program version

-w, --wait <seconds> set timeout waiting for finishing operations/<seconds>

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

CentOS8 - 怎么设置静态IP


常用命令组合

查看网络设备(网络设备状态等)

nmcli device

查看网络连接

ncmcli connection

创建网络连接

设置enp0s3网络的静态IPv4:192.168.57.100/24,网关:192.168.57.1,IP设置方式为manual

nmcli connection add type ethernet con-name enp0s3 ifname enp0s3 ipv4.addr 192.168.57.100/24 ipv4.gateway 192.168.57.1 ipv4.method manual

设置DHCP获取IP

nmcli c add type ethernet con-name enp0s3 ifname enp0s3 ipv4.method auto

修改IP

nmcli c modify enp0s3 ipv4.addr '192.168.57.200/24'

激活连接

nmcli c up enp0s3
CentOS8 - 怎么设置静态IP

关闭连接

nmcli down enp0s3

关闭并删除连接配置文件

nmcli delete enp0s3

查看网络具体信息

nmcli c show enp0s3

重载配置文件(不会马上生效)

nmcli c reload

重载配置文件(马上生效)

nmcli c up ens32
nmcli d reapply ens32
nmcli d connect ens32

激活网卡

nmcli d connect ens32

关闭无线网络

nmcli r all off

查看NetworkManager状态

nmcli n

开启NetworkManager状态

nmcli n on

关闭NetworkManager(谨慎执行,会断网)

nmcli n off

总结

CentOS8还兼顾了之前版本的配置,直接编辑文件也可以,但是还是使用命令生成比较准确。

CentOS8 - 怎么设置静态IP


分享到:


相關文章: