虚拟机网络设置选用桥接方式时,linux或者windows虚拟机均须要设置固定IP和DNS。html
vmware提供的三种连接方式linux
桥接模式:不提供动态IPwindows
NAT模式:提供动态IPbash
仅主机模式:提供动态IP 网络
三种模式分析: http://blog.sina.com.cn/s/blog_601bc5cf0101d32z.htmloop
NAT设置静态IP:测试
桥接设置静态IP: http://blog.csdn.net/testcs_dn/article/details/19554069ui
http://jingyan.baidu.com/article/455a99508be7cda167277865.htmlspa
1. 在终端中输入:vi /etc/sysconfig/network-scripts/ifcfg-eth0.net
2. 开始编辑,填写ip地址、子网掩码、网关、DNS等。其中“红框内的信息”是必须得有的。
3. 编辑完后,保存退出(:w保存, :q退出)。
4. 重启网络服务。service network restart或/etc/init.d/network restart。便可。
执行service network restart或/etc/init.d/network restart 时,若报错:
[root@localhost network-scripts]# /etc/init.d/network restart Shutting down loopback interface: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface eth0: Error: No suitable device found: no device found for connection 'System eth0'. [FAILED]
解决方法:http://blog.csdn.net/wwwyuanliang10000/article/details/19006409
1. ifconfig -a查看物理MAC HWADDR的值
2. vi编辑文件 /etc/sysconfig/network-script/ifcfg-eth0中修改ifconfig中查出的MAC HWADDR值;
3.从新执行执行service network restart或/etc/init.d/network restart 便可。
Centos7桥接的固定IP配置
请参考:https://my.oschina.net/Listening/blog/673560
su - root cd /etc/sysconfig/network-scripts/ cp ifcfg-eno16777736 ifcfg-eno16777736.bak vi ifcfg-eno16777736
编辑的内容为:
TYPE=Ethernet BOOTPROTO=static #静态地址 DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_PEERDNS=yes IPV6_PEERROUTES=yes IPV6_FAILURE_FATAL=no NAME=eno16777736 UUID=eca9008e-7ef6-4823-b2cd-95afc7e321dc DEVICE=eno16777736 ONBOOT=yes #开机自启 IPADDR=192.168.75.141 #设置为须要的实际虚拟机地址 GATEWAY=192.168.75.2 #同上 DNS1=192.168.75.2 #同上 DNS2=8.8.8.8
service network restart
测试IP可否连通
[root@localhost jdk]# ping www.baidu.com PING www.a.shifen.com (115.239.210.27) 56(84) bytes of data. 64 bytes from 115.239.210.27: icmp_seq=1 ttl=128 time=6.62 ms 64 bytes from 115.239.210.27: icmp_seq=2 ttl=128 time=6.77 ms 64 bytes from 115.239.210.27: icmp_seq=3 ttl=128 time=7.11 ms 64 bytes from 115.239.210.27: icmp_seq=4 ttl=128 time=6.45 ms 64 bytes from 115.239.210.27: icmp_seq=5 ttl=128 time=6.72 ms