第一种方法:nmcli
#nmcli connection modify eth0 ipv4.method manual ipv4.addresses 172.25.254.100/24 ipv4.gateway 172.25.254.2 ipv4.dns 114.114.114.114 autoconnect yes
#nmcli c up etho   //激活网卡命令(网卡早就配好,只是修改ip就不用输入这条命令了)
第二种方法:网卡可视化界面
#nm-connection-editor起一个网卡名称

写上IP、掩码、网关、dns服务器地址
也可以在Method选择DHCP服务自动获取

选择这块网卡

有IP且可以联网了

第三种方法:shell脚本命令
vim /bin/xxx.sh起一个shell脚本。
写入
#!/bin/bash                                 'shell执行'
hostnamectl hostname yyy$1.wxrd.org      '$1代表值'
cd /etc/NetworkManager/system-connections/
rm -fr *                                     '这条命令千万不要在服务器上用!后果很严重'
cat > eth0.nmconnection <<EOF
[connection]
id=eth0
type=ethernet
interface-name=eth0[ipv4]
method=manual
addressl=192.168.1.$1/24,192.168.1.2      'IP/掩码,网关;自行定义网段;网关用route-n命令查'
dns=114.114.114.114;                      '自行定义'EOFchmod 600 eth0.nmconnection                  '赋予可执行权限'nmcli connection reload
nmcli connection up eth0echo "192.168.1.$1  server$1.wxrd,org" >> /etc/hosts#chmod +x /bin/xxx.sh                         '赋予文件可执行权限‘这样,就可以用了(这台放起来)
克隆出一个他的克隆虚拟机
#xxx.sh 100                                 '执行'这台名称为yyy100.wxrd.org 且IP地址为192.168.1.100/24的主机诞生啦
证明脚本设定好啦!
以上三种设置IP的方法
拜拜-----------------------------------------------------------------------------------------------------(疯狂尖叫)