NM网络管理
nmcli是redhat7或者centos7之后的命令,该命令可以完成网卡上所有的配置工作,并且可以写入配置文件,永久生效
debian 10 安装:apt-get install network-manager
/etc/NetworkManager/NetworkManger.conf/
[main] plugins=ifupdown,keyfile,ofono dns=dnsmasq [ifupdown] managed=true
修改了/etc/network/interfaces之后,NetworkManger.conf中设置会自动修改为false
1、修改计算机名:
hostnamectl set-hostname smc.com
nmcli g hostname webnignx
2、查看网卡信息
nmcli connection show
nmcli connection show eth0
3、显示所有设配状态
nmcli device status
4、显示所有活动连接
# nmcli connection show --active
5、删除一个网卡连接
# nmcli connection delete eth0
6、添加一个网卡连接
# nmcli connection add type ethernet con-name eth0 ifname eno33554992
7、
网络接口的启用与停用:
停用:
# nmcli connection down eth0
启用:
# nmcli connection up eth0
8、
给eth0添加一个IP(IPADDR)
# nmcli connection modify eth0 ipv4.addresses 192.168.0.58
给eth0添加一个子网掩码(NETMASK)
# nmcli connection modify eth0 ipv4.addresses 192.168.0.58/24
IP获取方式设置成手动(BOOTPROTO=static/none)
# nmcli connection modify eth0 ipv4.method manual
添加一个ipv4
# nmcli connection modify eth0 +ipv4.addresses 192.168.0.59/24
删除一个ipv4
# nmcli connection modify eth0 -ipv4.addresses 192.168.0.59/24
添加DNS
# nmcli connection modify eth0 ipv4.dns 114.114.114.114
删除DNS
# nmcli connection modify eth0 -ipv4.dns 114.114.114.114
添加一个网关(GATEWAY)
# nmcli connection modify eth0 ipv4.gateway 192.168.0.2
可一块写入:
nmcli connection modify eth0 ipv4.dns 114.114.114.114 ipv4.gateway 192.168.0.2
9、查看wifi
nmcli d wifi list wlan0
10、修改网卡名称
删除网卡连接
# nmcli connection delete eno16777736
修改内核参数配置文件
# vi /etc/default/grub
重新生成grub
# grub2-mkconfig -o /boot/grub2/grub.cfg
重启
#reboot
添加网卡
# nmcli connection add type ethernet con-name eth0