win10 VMware 虚拟机 实现桥接模式
VMware的桥接模式,可以让大家像拥有另外一台不同操作系统的电脑一样在局域网中。同样可以来上网,可以和局域网中的其他机器一样通信,甚至可以暴露ip与端口到公网中,这样其他机器或者网页等也能访问它。
环境:
宿主机:win10
软件:VMware
虚拟机:Ubuntu 18.04
前提条件:已经在宿主机中安装好了虚拟主机Ubuntu
一、查看物理机(宿主机)在局域网内的信息
点击WIFI图标,右击 打开网络和internet设置,点击详细信息,不要勾选共享。
三、设置虚拟机,需要在关闭虚拟机
桥接到的网络为详细信息连接的网络。
四、现在进行开机,进到虚拟机中设置 ,这是可视化的设置
1、配置静态IP地址:
运行ifconfig 查看连接
或者 ip a
看到为ens33
sudo gedit /etc/network/interfaces
原内容有如下4行:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
以上表示默认使用DHCP分配IP,修改为如下:(地址与win10后三位不同,其他一样)
auto lo
iface lo inet loopback
auto ens33
iface ens33 inet static
address 192.168.31.113
netmask 255.255.255.0
gateway 192.168.31.1
保存退出。
注意:只需要设置address(IP地址)、netmask(子网掩码)、gateway(网关)这三项就OK,
1点击save保存,查看设置结果,ctrl+alt+t 可以呼出终端 输入ifconfig 查看虚拟机的IP地址
可以看到设置成功, 现在进行ping 操作,ping www.baidu.com,如果不成功进行下面操作。
sudo gedit /etc/systemd/resolved.conf
修改为以下内容
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details
[Resolve]
DNS=8.8.8.8
#FallbackDNS=
#Domains=
LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes