VMware 虚拟机如何连接网络

1.首先打开自己的电脑中的服务,启动VM开头的服务


2.网络和Internet设置->打开适配器选项,找到自己的网络,右击属性->共享,都画勾


3.将VM8启用



3.查看VM8的IP(我这一般设为共享后,会弹出提示,这只能设置IP为192.168.137.1)


4.打开VM虚拟机,选择你使用的操作系统右击,点击设置选项,选择NAT模式并选择启动时连接


5.选择完后点击虚拟机页面上的编辑进入虚拟网络编辑器 ,按如下配置,注意子网IP,网关IP中192.168.137.0,中137要和

上面查看自己电脑的VM8的IP在同一个网段




6.登陆虚拟主机,设置ip ,vi /etc/sysconfig/network-scripts/ifcfg-ens33


设置完重启网关service network restart

查看ip


7.yum -y install wget试一下

阿哦,报错了:

[root@mytest ~]# yum -y install wget
已加载插件:fastestmirror
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; 未知的错误"
 One of the configured repositories failed (未知),
 and yum doesn't have enough cached data to continue. At this point the only
 safe thing yum can do is fail. There are a few ways to work "fix" this:
     1. Contact the upstream for the repository and get them to fix the problem.
     2. Reconfigure the baseurl/etc. for the repository, to point to a working
        upstream. This is most often useful if you are using a newer
        distribution release than is supported by the repository (and the
        packages for the previous distribution release still work).
     3. Run the command with the repository temporarily disabled
            yum --disablerepo=<repoid> ...
     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:
            yum-config-manager --disable <repoid>
        or

            subscription-manager repos --disable=<repoid>

解决办法:

vi /etc/resolv.conf 加入nameserver

# Generated by NetworkManager
nameserver 8.8.8.8
nameserver 8.8.4.4

search localdomain

说明:

文件/etc/resolv.conf 配置DNS 客户,它包含了主机的域名搜索顺序和DNS服务器的地址,每一行应包含一个关键字和一个或多个的由空格隔开的参数。 

nameserver 表明DNS 服务器的IP 地址。可以有很多行的nameserver,每一个带一个I P 地址。在查询时就按nameserver 在本文件中的顺序进行,且只有当第一个nameserver 没有反应时才查询下面的nameserver. 

domain 声明主机的域名。很多程序用到它,如邮件系统;当为没有域名的主 
机进行DNS 查询时,也要用到。

8.然后就可以上网了


猜你喜欢

转载自blog.csdn.net/lavendYu/article/details/80373708