nmcli命令学习(必须会,CentOS8都默认nmcli了)
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了nmcli命令学习(必须会,CentOS8都默认nmcli了),小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含4603字,纯文字阅读大概需要7分钟。
内容图文
nmcli命令
可以参考这个:https://mp.weixin.qq.com/s/y64vMJqfbtDGXcTDz6R-mQ
<font color=red>nmcli可以自动补全,还是比较容易的</font>
只敲nmcli显示所有网卡信息:
[root@linux1 ~]# nmcli
ens33: connected to ens33
"Intel 82545EM"
ethernet (e1000), 00:0C:29:D3:DD:51, hw, mtu 1500
ip4 default
inet4 192.168.38.123/24
route4 192.168.38.0/24
route4 0.0.0.0/0
route4 172.18.0.0/16
inet6 fe80::20c:29ff:fed3:dd51/64
route6 ff00::/8
route6 fe80::/64
ens37: connected to Wired connection 1
"Intel 82545EM"
ethernet (e1000), 00:0C:29:D3:DD:5B, hw, mtu 1500
inet4 192.168.38.142/24
route4 0.0.0.0/0
route4 192.168.38.0/24
inet6 fe80::a439:f7bd:b0c0:84be/64
route6 fe80::/64
route6 ff00::/8
nmcli一级选项
[root@linux1 ~]# nmcli
agent device help networking
connection general monitor radio
查看所有网络接口信息
[root@linux1 ~]# nmcli connection show
NAME UUID TYPE DEVICE
ens33 c96bc909-188e-ec64-3a96-6a90982b08ad ethernet ens33
Wired connection 1 97f5b522-19ca-3a36-9ee2-7ad076028521 ethernet ens37
查看指定接口信息
[root@linux1 ~]# nmcli connection show ens33
connection.id: ens33
connection.uuid: c96bc909-188e-ec64-3a96-6a90982b08ad
connection.stable-id: --
connection.type: 802-3-ethernet
connection.interface-name: ens33
connection.autoconnect: yes
connection.autoconnect-priority: 0
[root@linux1 ~]# nmcli device show ens33
GENERAL.DEVICE: ens33
GENERAL.TYPE: ethernet
GENERAL.HWADDR: 00:0C:29:D3:DD:51
GENERAL.MTU: 1500
GENERAL.STATE: 100 (connected)
GENERAL.CONNECTION: ens33
显示所有活动链接
[root@linux1 ~]# nmcli connection show --active
NAME UUID TYPE DEVICE
ens33 c96bc909-188e-ec64-3a96-6a90982b08ad ethernet ens33
Wired connection 1 97f5b522-19ca-3a36-9ee2-7ad076028521 ethernet ens37
删除一个网卡连接
[root@linux1 ~]# nmcli connection show
NAME UUID TYPE DEVICE
ens33 c96bc909-188e-ec64-3a96-6a90982b08ad ethernet ens33
Wired connection 1 97f5b522-19ca-3a36-9ee2-7ad076028521 ethernet ens37
#删除
[root@linux1 ~]# nmcli connection delete Wired\ connection\ 1
Connection 'Wired connection 1' (97f5b522-19ca-3a36-9ee2-7ad076028521) successfully deleted.
#查看
[root@linux1 ~]# nmcli connection show
NAME UUID TYPE DEVICE
ens33 c96bc909-188e-ec64-3a96-6a90982b08ad ethernet ens33
手动给ens37配个IP,这个是永久的,会生成配置文件
# 查看网卡名
[root@linux1 ~]# ip addr show ens37
4: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:d3:dd:5b brd ff:ff:ff:ff:ff:ff
#开始表演
# 网卡类型为ethernet ifname为网络接口名字ens37,ip,网关,BOOTPROTO为自动
[root@linux1 ~]# nmcli connection add type ethernet ifname ens37 ipv4.addresses 192.168.38.
142/24 ipv4.gateway 192.168.38.2 ipv4.method manual
Connection 'ethernet-ens37' (5397a06b-81d2-47ce-a06f-0c76af02c5b4) successfully added.
[root@linux1 ~]# nmcli connection show
NAME UUID TYPE DEVICE
ens33 c96bc909-188e-ec64-3a96-6a90982b08ad ethernet ens33
ethernet-ens37 5397a06b-81d2-47ce-a06f-0c76af02c5b4 ethernet ens37
# 查看生成的配置文件
[root@linux1 ~]# cat /etc/sysconfig/network-scripts/ifcfg-ethernet-ens37
修改IP或某些网络参数
#原来的样子
[root@linux1 ~]# nmcli connection show
NAME UUID TYPE DEVICE
ens33 c96bc909-188e-ec64-3a96-6a90982b08ad ethernet ens33
ethernet-ens37 5397a06b-81d2-47ce-a06f-0c76af02c5b4 ethernet ens37
#修改后的样子
[root@linux1 ~]# nmcli connection modify ethernet-ens37 con-name ens37
[root@linux1 ~]# nmcli connection show
NAME UUID TYPE DEVICE
ens33 c96bc909-188e-ec64-3a96-6a90982b08ad ethernet ens33
ens37 5397a06b-81d2-47ce-a06f-0c76af02c5b4 ethernet ens37
#添加DNS
[root@linux1 ~]# nmcli connection modify ens37 +ipv4.dns 123.123.123.123
增加IP、删除IP
[root@linux1 ~]# nmcli connection modify ens37 +ipv4.addresses 192.168.38.161/24
[root@linux1 ~]# nmcli connection modify ens37 -ipv4.addresses 192.168.38.161/24
重启网路
[root@linux1 ~]# nmcli connection reload
[root@linux1 ~]# systemctl restart network
内容总结
以上是互联网集市为您收集整理的nmcli命令学习(必须会,CentOS8都默认nmcli了)全部内容,希望文章能够帮你解决nmcli命令学习(必须会,CentOS8都默认nmcli了)所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。