Samba:如何访问 Virtualbox 来宾上的共享(在 NAT 模式下)

her*_*ron 13 server ssh virtualbox samba 12.10

我的操作系统:Windows 8

Virtualbox 来宾:Ubuntu 12.10 服务器

我在 vbox 来宾上配置了 apache 服务器并将 http、https、ssh 端口成功映射到 ubuntu 服务器。它运行良好,没有任何问题。

我的网卡是NAT模式。经过一番研究,我在来宾系统上安装了 samba。我需要在 Windows 8 上映射 /var/www/ 文件夹,以便我可以从 Windows 直接在来宾服务器内工作。

这是我的 smb.conf

[share]
 comment = "Vbox server share"
 path = /
 writable = yes
 read only =no
 browseable = yes
 force directory mode = 777
 force create mode = 777
 force security mode = 777 
force directory security mode = 777
 hide dot files = no
 create mask = 0777
 directory mask = 0777
 valid users = @users, tural, root
 delete readonly = yes
 guest ok = yes
workgroup = WORKGROUP
Run Code Online (Sandbox Code Playgroud)

我知道映射在网络处于桥接模式时有效,但我不想让我的 vbox 服务器对网络可见。

此外,我配置了 windows 主机文件并使用 vbox nat 映射了端口 80,这样,当我打开一些重定向到 windows 上的 localhost 的域时,它会从 virtualbox webserver 获取数据。如果做桥接,我将无法打开访客网络服务器

有没有其他方法可以通过 NAT 或其他方式使驱动器映射成为可能?

ntg*_*ntg 9

仅将第二个适配器配置为主机,将 VM 上的第二个接口设置为不干扰本地网络的静态 ip,例如,将 /etc/network/interfaces 设置为:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

# The host network interface
#auto eth1
#iface eth1 inet dhcp
auto eth1
iface eth1 inet static
   address 192.168.36.2
   netmask 255.255.255.0
   network 192.168.36.0
   gateway 192.168.36.1
   dns-nameservers 192.168.36.1
Run Code Online (Sandbox Code Playgroud)

然后从 Windows 网络转到其属性并设置一个不干扰本地网络的静态 ip,例如: 在此处输入图片说明 在此处输入图片说明 在此处输入图片说明 在此处输入图片说明 在此处输入图片说明


Jav*_*era 2

这个设置不能用啊 您可以将 smb 端口映射到 VirtualBox,但随后您的主机将失去 smb 连接。

如果您只想从来宾访问某些主机文件夹,您可以使用共享文件夹,这是一种有限的 smb 连接。您将需要安装来宾添加项。它会完全按照您的意愿行事,但仅限于主人和客人。我的意思是没有其他机器能够访问这些文件夹。

还有一些其他选项,例如使用两个接口,一个 NAT,另一个使用 Bridge 或 Host-only。