搭建1、虚拟机中CentOS指定ip

1.修改vm上网方式为 host only
2.启动虚拟机
3.rm -rf /etc/udev/rules.d/70-persistent-net.rules
4.修改虚拟机的网络配置:
  (1)vi /etc/sysconfig/network-scripts/ifcfg-eth0
  (2)修改DEVICE的值为eth0
  (3)删掉 HWADDR行
  (4)注释掉 BOOTPROTO=dhcp
  (5)添加:IPADDR=192.168.0.10X
      NETMASK=255.255.255.0
      GATEWAY=192.168.0.1

7.vi /etc/resolv.conf ,将nameserver 192.168.0.1  #不配置,ping www.baidu.com时,提示ping: unknown host www.baidu.com

10.关闭防火墙:
service iptables stop
永久关闭:chkconfig iptables off
检查是否关闭:service iptables status
11.关闭selinux
vi /etc/selinux/config
注释掉 SELINUX=enforcing
SELINUX=targeted
增加 SELINUX=disabled


5.本机网络配置中 VMware Network Adapter VMnet1,ip改为 192.168.0.1,子网掩码 255.255.255.0
6.将本机上网网络适配器共享给VMware Network Adapter VMnet1
8.重启虚拟机、或重启网卡 service network restart
9.ping 本机、网络,本机ping 虚拟机


原文地址:https://www.cnblogs.com/stay-sober/p/4157355.html