环境准备
虚拟机版本:centos7
安装环境:vmware17
1、设置网络连接
虚拟机-设置-网络适配器-NAT模式
2、查看子网信息
编辑-虚拟网络编辑器-NAT模式-NAT设置 查看子网ip和网关ip 下一步要用
3、修改配置文件
bash
vim /etc/sysconfig/network-scripts/ifcfg-ens33
DNS1和GATEWAY 写一样的,即上一步看到的网关IP。
ONBOOT 如果是no 改成yes
IPADDR前三段与子网IP保持一致,最后一段可以自定义(0-255),我这里为了方便记忆 设置成了192.168.110.111
bash
DNS1=192.168.110.2
GATEWAY=192.168.110.2
IPADDR=192.168.110.111

ESC :wq! 回车
保存 退出
重启网络服务
bash
service network restart

4、测试
bash
ifconfig

bash
ping baidu.com

完成 虚拟机ip已经固定为192.168.110.111