vwware虚拟机没法链接外网

一、问题:动态IP时链接外网没有问题,可是将IP改成静态IP时发现没有办法链接外网网络

 

查看文件/etc/resolv.conf,里面的内容所有都被注释编辑器

[root@jenkins network-scripts]# more /etc/resolv.conf
# Generated by NetworkManager


# No nameservers found; try putting DNS servers into your
# ifcfg files in /etc/sysconfig/network-scripts like so:
#
# DNS1=xxx.xxx.xxx.xxx
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.comoop

在eth0文件中增长一行语句
[root@jenkins network-scripts]# vi ifcfg-eth0 

DEVICE=eth0
BOOTPROTO=none
#BOOTPROTO=dhcp
IPADDR=192.168.0.173
IPV6INIT=no
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Ethernet
UUID="9086dd6f-6c00-49be-ad52-28ab87f2dcb7"
NAME="System eth0"
HWADDR=00:0c:29:c2:96:4a

NETMASK=255.255.255.0
GATEWAY=192.168.0.1
USERCTL=no
DNS1=192.168.0.1spa

重启network
[root@jenkins network-scripts]# service network restart
Shutting down interface eth0:  Device state: 3 (disconnected)
                                                           [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/5
                                                           [  OK  ]rest

能够链接外网
[root@jenkins network-scripts]# ping www.baidu.com
PING www.a.shifen.com (61.135.169.121) 56(84) bytes of data.
64 bytes from 61.135.169.121: icmp_seq=1 ttl=54 time=2.51 msserver

再次查看/etc/resolv.conf文件
[root@jenkins network-scripts]# more /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.0.1

blog

 

二、问题ip

虚拟机关闭的状态下进行了win10的更新,虚拟机打开以后处于没网状态,没法链接到桥接模式虚拟机

首先将虚拟机挂起或者关闭jenkins

点击编辑-->虚拟网络编辑器

 

还原默认设置

以后点击VMnet0

桥接到本地网卡便可

打开虚拟机,设置为桥接模式

相关文章
相关标签/搜索