Ber*_*ard 7 networking virtualbox ubuntu
在 Virtualbox 4.3.26 版中,我想安装 Ubuntu 16.04 客户端。网络配置是适配器 1:桥接适配器名称:eth0 适配器 2:NAT
通过这种配置,我确实可以访问互联网,但不能访问我的本地网络。
我试过:static-ip-in-virtualbox-machine-with-ubuntu-16-04但是当设置为仅主机时,我无法选择任何东西。
我已阅读Virtualbox 手册第 6 章,但找不到解决方案。
我尝试过如何重命名网卡,但添加规则对我不起作用。
在我的其他虚拟机客户端中,我必须添加客户端(Ubuntu)接口文件(/etc/network/interfaces),结果是:
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto eth1
iface eth1 inet static
dns-nameservers 192.168.1.70 192.168.1.1
address 192.168.1.66
gateway 192.168.1.1
Run Code Online (Sandbox Code Playgroud)
在 virtualbox 网络设置适配器 1 中:桥接适配器,名称:eth0
通过此配置,我可以使用其他(Ubuntu 14.04)Virtualbox 客户端访问我的本地网络和 Internet。
Ubuntu 16.04 中的名称系统已更改,不再使用 eth0 而是通过使用 ifconfig 进行检查:
me@vBox1b-client:~$ ifconfig
enp0s3 Link encap:Ethernet HWaddr 08:00:27:9e:aa:c9
inet addr:192.168.1.78 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe9e:aac9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:41 errors:0 dropped:0 overruns:0 frame:0
TX packets:84 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4304 (4.3 KB) TX bytes:8988 (8.9 KB)
enp0s8 Link encap:Ethernet HWaddr 08:00:27:17:a7:e6
inet addr:10.0.3.15 Bcast:10.0.3.255 Mask:255.255.255.0
inet6 addr: fe80::a16b:7a82:bf0b:7247/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4 errors:0 dropped:0 overruns:0 frame:0
TX packets:67 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1328 (1.3 KB) TX bytes:7953 (7.9 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:10 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:534 (534.0 B) TX bytes:534 (534.0 B)
Run Code Online (Sandbox Code Playgroud)
因此,根据这些信息,我将接口文件更改为:
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto enp0s3
iface enp0s3 inet static
dns-nameservers 192.168.1.70 192.168.1.1
address 192.168.1.66
gateway 192.168.1.1
Run Code Online (Sandbox Code Playgroud)
我重新启动,确实可以访问本地网络,但不能再访问 Internet。
因此,在 Virtualbox 服务器中,我想将名称为 eth0 的适配器 1 更改为 enp0s3,但我根本无法更改名称。
DNS似乎没问题。
当地的 :
ping mylocal.com
PING mylocal.com (192.168.1.73) 56(84) bytes of data.
64 bytes from 192.168.1.73: icmp_seq=1 ttl=64 time=0.961 ms
Run Code Online (Sandbox Code Playgroud)
DNS 可以找到本地 IP 地址,IP 地址会做出响应。
互联网(全球):
ping nu.nl
PING nu.nl (62.69.166.254) 56(84) bytes of data.
From 192.168.1.66 icmp_seq=1 Destination Host Unreachable
Run Code Online (Sandbox Code Playgroud)
另外全局DNS可以找到IP地址,但是IP地址没有响应。
使用的 DNS 服务器:
nslookup host
Server: 192.168.1.70
Address: 192.168.1.70#53
Run Code Online (Sandbox Code Playgroud)
可能与 Virtualbox MAC 地址存在冲突,所以我在 Virtualbox 管理器中刷新了它们,但没有结果。
我有三个问题:
小智 11
当您添加新的网络适配器并设置网关时,它将成为“默认网关”,并且所有 Internet 流量都通过它重定向,在您的案例中为 gateway 192.168.1.1。
尝试gateway 192.168.1.1在您的网络设置中删除/评论。我也使用两个网络适配器。
第一个是“NAT”类型,用于 Internet 访问并设置为dhcp. 虚拟机之间连接的“仅主机”中的第二个是静态 IP。不要为其设置网关,因为它仅用于 VM 之间的连接。
您还需要添加“仅主机”适配器表单文件 → 首选项 → 网络 → 仅主机网络。
在这里你可以找到详细的解释http://www.slideshare.net/powerhan96/networking-between-host-and-guest-v-ms-in-virtual-box,这是我的 /etc/network/interfaces
# The Loopback network interface
auto lo
iface lo inet loopback
#The Primary network interface
auto enp0s3
iface enp0s3 inet dhcp
#The secondary network interface (host-only)
auto enp0s8
iface enp0s8 inet static
address 192.168.56.101
network 192.168.56.0
netmask 255.255.255.0
broadcast 192.168.56.255
#gateway 192.168.56.1 NOTE: remove/comment gateway or set enp0s3 as a default gateway.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25330 次 |
| 最近记录: |