Reference:
http://www.doc88.com/p-915707596190.html---Installing Samba
Http://my.oschina.net/u/2260265/blog/405598?fromerr=eAmxiwAB
In daily work, often use virtual machine, install server inside, set up service-side environment for development debugging, this kind of usage scenario generally requires the virtual machine to have normal access to the external network, and the host must have access to the virtual machine. In VirtualBox, virtual machine access to the external network is generally the simplest configuration of the NAT mode, but in pure NAT mode, the host cannot access the virtual machine, you must use the bridged or host-only mode. In both modes, the virtual machine can obtain an available IP address, and the host will be able to access the virtual machine via that IP address.
About VirtualBox network access mode, do not know the students can Google, this part of the information is actually quite complete, this article is mainly a simple introduction (record) in the VirtualBox virtual machine using NAT mode access to the external public network (Internet), Combined with host-only mode, the host can also access the virtual machine's configuration with the virtual machine's static IP address. The benefit of this configuration relative to the simple use of the bridged mode is that, even without an external public network, the host can access the virtual machine without any impact and will not affect the use.
In bridged mode, the virtual machine and the host are in the same position, like a real host in the local area network, can be assigned to a network of independent IP, all network functions and in the network as a real machine, the network of other machines (including host) can also access to this virtual machine. Also, if the network is disconnected, the host is not able to access the virtual machine even if the virtual machine and host are actually on a single physical machine. And the host-only mode, can be understood as VirtualBox in the host to simulate a virtual machine for the use of a network card, all virtual machines are connected to the network card, the virtual machine can access the host through the network card IP, while VirtualBox provide a DHCP service, A virtual machine can have an intranet IP that the host can use to access the virtual machine. If you use Host-only mode purely, the virtual machine cannot connect to an external public network.
In the case of external networks, if you need to open the virtual machine to other machines in the network access, such as to let colleagues connected to the virtual machine for development testing work, then you can directly use the bridged mode, this mode only needs to occupy an IP address in the public network, but in the daily use of the environment, Sometimes there is not necessarily a public network can be used, if the use of bridged mode, the virtual machine is not connected, development work can not be done, at this time host-only mode is a good choice, if the NAT mode, if the external public network is available, the virtual machine can also access the external public network.
The following is a brief description of the configuration you need to make when using these modes.
VirtualBox installed on my machine (Windows 10), I installed Ubuntu in VirtualBox, I want to access the network Ubuntu,virtualbox after installation will be assigned a network card in Windows 7-Virtual network card, in the control Panel \ The network and Internet\ network connection can see VirtualBox host-only networks, the IP of this network card is generally:
Typically, this NIC is not enabled.
Local network:
Configure the virtual machine to be able to surf the Internet:
Right-click the VirtualBox host-only network--> property, and in the Properties dialog box, select Virtualbox_bridged_networking_driver. Or
This is to confirm that the VirtualBox host-only network NIC works. This allows the network to be accessed from the left virtual machine, just like the host. Here are some configurations that need to access the virtual machine from the host.
1. Installation of the Samba software package
Using the source installation, enter the following command in the terminal:
#sudo Apt-get Install Samba
#sudo Apt-get Install Smbclient
To start the Samba server, simply execute the following command:
#sudo/etc/init.d/samba Start
Samba Server main configuration file is/etc/samba/smb.conf
First in the VirtualBox in the global configuration (outbound shortcut Ctrl+g) interface of the network configuration, click on the right to add a button, adding a host-only network. To view the details of the network, you can see:
As you can see, the network is 192.168.56.0, and the IP address that is available for allocation is 192.168.56.101-192.168.56.254.
Turn on the network configuration of the virtual machine, select Network address translation (NAT) for the connection of network card 1, and connect the network card 2 as "host only (Host-only) adapter" as shown in:
(where promiscuous mode select Deny or select all Allow, the host computer input virtual machine IP address Access can be virtual machine, dizzy)
If you use the bridged mode, you need to select the connection mode as "Bridge network card".
After saving, start the virtual machine, virtual machine in Ubuntu server 12.04, for example, open the configuration file/etc/network/interfaces add the following configuration:
# The Loopback network interface Auto Lo iface lo inet loopback
# The primary network interface auto eth0 iface eth0 inet DHCP
# Virtualbox Host-only Modeauto
Eth1 Iface
Eth1 inet Static
Address 192.168.56.190
Netmask 255.255.255.0
Network 192.168.56.0
# Virtualbox Bridged mode
#auto eth1
#iface eth1
inet Static
#address 192.168.0.190
#netmask 255.255.255.0
#gateway 192.168.0.1
To view my IP:
My IP configuration is as follows:
The 16.04 version setting results are as follows:
The IP is displayed as follows:
Network card 2 must be the access network cable that option to hook, otherwise after win+r input \\192.168.56.190 is unable to open. You can ping to see if you can access:
(Can ping in 16.04, but it is not possible to access the virtual machine from the host, very strange)
This configuration sets the IP address of the virtual machine on the internal network to static assignment (192.168.56.190), which allows the host to bind the IP access virtual machine to the hosts. After saving the configuration, perform the following command to restart the network service:
$ sudo/etc/init.d/networking Restart
Enables virtual machines to use NAT to access the external network normally through host computers, and because the host-only mode is used, the host can access the virtual machine through the virtual machine's IP address on the internal network, even if the external network is not
Also does not affect the host's access to the virtual machine.
You can now access the virtual machine, but you cannot access the folder yet. Create a share folder under the root directory. mkdir Share change folder permissions Chmod-r 777 Share/chmod 777./share
This allows you to read and write this folder in Windows. Or you can choose right-click Properties in Ubuntu.
This allows the host to access the virtual machine, and if not, you can re-execute the following command:
#sudo Apt Install Samba
#sudo Apt Install smbclient
#sudo/etc/init.d/samba Start
Start the Samba server.
Access virtual machine (equivalent server) via putty: (reference: http://www.myhack58.com/Article/60/63/2012/35323.htm)
First, you can ping the server, if you cannot log in again to reinstall and start the following server (Ubuntu default installed openssh-client)
sudo apt-get install openssh-server (I do not install this in 16.04 can also ping to pass)
If you now open Putty connect the virtual machine will appear no active, this time need to check if you connect this IP in the virtual machine is allowed, can be viewed in the virtual machine through Ifconfig:
For example, the following is not possible:
The following is OK: As long as the network icon on the virtual machine right-click on the Start Network 2 (this is a static network, and host communication)
Turn on Ssh-server service:/ETC/INIT.D/SSH Start (if this is not installed, an error occurs immediately when the putty is connected to the virtual machine)
Ssh-server configuration file is located in/Etc/ssh/sshd_config, where you can define the SSH service port, the default port is 22, you can define yourself as a different port number, such as 222. Then restart the SSH service:
Sudo/etc/init.d/ssh Resart
Putty Configuration Reference: http://www.cnblogs.com/lfire/archive/2012/08/24/2653882.html
Putty: Window-->translation in the Remote Character set encoding method is modified to UTF-8 to avoid the Putty Command window in addition to English language garbled phenomenon;
Host name or IP address input: 192.168.56.190 port Set default value 22
The right side of the session window has a connection type, tick SSH
The larger the line of Scrollback setting in window, the more records can be rolled back
Connection, data, Auto-login username Enter the user name of Ubuntu login
Click Save, Load, open
WINDOWS10 access to the linux15.10/16.04 system of the VirtualBox virtual machine and the configuration of the virtual machine accessed with putty