Linux

 

 

 

 

Setting a Network Interface between Host and Guest

 

 

In default configuration of Virtual Box, the network on Host PC (Windows 10 in my case) and the network in Virtual PC (Ubuntu in my case) does not belong to the same network. It means that there is no network connection between the host PC and Virtual PC. This caused a lot of trouble to transfer files between the Host and Virtual PC. At first, I setup a shared folder between the host and virtual PC as described here. But I hoped I have IP connection between the Host PC and Virtual PC and use FTP based application (like WinSCP) to exchange files. This is why I decided to investigate on this and write a note about it.

 

NOTE : Virtual box version that I used for this tutorial is v5.2.6. If you use the different version of Virtual Box, you would see a little bit different screenshot from what you see in this tutorial, but you would see the general idea from this tutorial even if you are using a different version.

 

 

 

Check up before Setting the Interface

 

Take a look at the network configuration of your Host PC. Following is the configuration on my PC before setting the interface. Of course, this is just for your reference. This will be different from what you see on your PC.

 

Network configuration on Host (Windows 10) before Network Interface Setting

Windows IP Configuration

 

   Host Name . . . . . . . . . . . . : ******

   Primary Dns Suffix  . . . . . . . : ******

   Node Type . . . . . . . . . . . . : Peer-Peer

   IP Routing Enabled. . . . . . . . : No

   WINS Proxy Enabled. . . . . . . . : No

   DNS Suffix Search List. . . . . . : ******

                                       ******

 

Ethernet adapter Ethernet 2:

 

   Media State . . . . . . . . . . . : Media disconnected

   Connection-specific DNS Suffix  . :

   Description . . . . . . . . . . . : PANGP Virtual Ethernet Adapter

   Physical Address. . . . . . . . . : 02-50-41-00-00-01

   DHCP Enabled. . . . . . . . . . . : No

   Autoconfiguration Enabled . . . . : Yes

 

Ethernet adapter Ethernet:

 

   Media State . . . . . . . . . . . : Media disconnected

   Connection-specific DNS Suffix  . : ******

   Description . . . . . . . . . . . : Intel(R) Ethernet Connection (4) I219-LM

   Physical Address. . . . . . . . . : 54-E1-AD-25-FD-00

   DHCP Enabled. . . . . . . . . . . : Yes

   Autoconfiguration Enabled . . . . : Yes

 

Wireless LAN adapter Local Area Connection* 2:

 

   Media State . . . . . . . . . . . : Media disconnected

   Connection-specific DNS Suffix  . :

   Description . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter

   Physical Address. . . . . . . . . : 00-28-F8-E7-45-F1

   DHCP Enabled. . . . . . . . . . . : Yes

   Autoconfiguration Enabled . . . . : Yes

 

Wireless LAN adapter Wi-Fi:

 

   Connection-specific DNS Suffix  . : ******

   Description . . . . . . . . . . . : Intel(R) Dual Band Wireless-AC 8265

   Physical Address. . . . . . . . . : 00-28-F8-E7-45-F0

   DHCP Enabled. . . . . . . . . . . : Yes

   Autoconfiguration Enabled . . . . : Yes

   Link-local IPv6 Address . . . . . : fe80::b418:e5c0:f2e2:b1%13(Preferred)

   IPv4 Address. . . . . . . . . . . : ******(Preferred)

   Subnet Mask . . . . . . . . . . . : 255.255.254.0

   Lease Obtained. . . . . . . . . . : Friday, February 2, 2018 3:58:49 PM

   Lease Expires . . . . . . . . . . : Saturday, February 3, 2018 3:58:48 PM

   Default Gateway . . . . . . . . . : ******

   DHCP Server . . . . . . . . . . . : ******

   DHCPv6 IAID . . . . . . . . . . . : 83896568

   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-20-CB-08-63-54-E1-AD-25-FD-00

   DNS Servers . . . . . . . . . . . : ******

   Primary WINS Server . . . . . . . : ******

   NetBIOS over Tcpip. . . . . . . . : Enabled

 

 

 

 

Following is the network configuration I get on my Virtual PC (Ubuntu in Virtual Box). This would be different from what you see in your PC.

 

Network configuration on Guest (Ubuntu) before Network Interface Setting

enp0s3    Link encap:Ethernet  HWaddr 08:00:27:d5:84:25  

          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0

          inet6 addr: fe80::4b94:ece7:ee76:500d/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:9533 errors:0 dropped:0 overruns:0 frame:0

          TX packets:6220 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:6337711 (6.3 MB)  TX bytes:704862 (704.8 KB)

 

enp0s8    Link encap:Ethernet  HWaddr 08:00:27:39:57:f8  

          inet addr:10.0.3.15  Bcast:10.0.3.255  Mask:255.255.255.0

          inet6 addr: fe80::3c4d:2117:f3ea:6bcb/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:48 errors:0 dropped:0 overruns:0 frame:0

          TX packets:352 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:5824 (5.8 KB)  TX bytes:57720 (57.7 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:368 errors:0 dropped:0 overruns:0 frame:0

          TX packets:368 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:37042 (37.0 KB)  TX bytes:37042 (37.0 KB)

 

 

Except the local loopback interface lo, you see there are two network interface named epn0s3 and epn0s8. These two interface configuration can be seen in Vitural Box Network Setting as shown below.

 

Following shows the interface setting for enp0s3. You would know this is for enp0s3 by comparing MAC address with HWaddr shown above.

 

 

 

Following shows the interface setting for enp0s3. You would know this is for enp0s8 by comparing MAC address with HWaddr shown above.

 

 

 

 

Setting Up the Interface

 

Now let's setup a Network Interface between the Host PC and Virtual PC.  Click on [Settings] button as shown below.

 

 

 

As shown in previous section, Adapter 1 and Adapter 2 are used for the default Network Interface for my PC. So I will configure Adapter 3 for the new interface between Host PC and Virtual PC.  Default setting for Adapter 3 is as follows.

 

 

 

Configure the settings for Adapter 3 as shown below and click [OK].

 

 

 

NOTE : In some case, you may not see the item [Host-only Adapter] in 'Attached to' drop down box in the above configuration. In this case, check the network adapter settings in the host PC (Windows 10 PC in my case) and make it sure you find 'VirtualBox Host-Only Network' and it is 'Enabled' as shown below.

 

 

 

 

Check up after Setting the Interface

 

Now let's check if the new interface is successfully set. First, check the ipconfig on the host PC (Windows 10 PC in my case). I can find a new interface is added as shown below.

 

Network configuration on Host (Windows 10) after Network Interface Setting

Windows IP Configuration

 

   Host Name . . . . . . . . . . . . : ******

   Primary Dns Suffix  . . . . . . . : ******

   Node Type . . . . . . . . . . . . : Peer-Peer

   IP Routing Enabled. . . . . . . . : No

   WINS Proxy Enabled. . . . . . . . : No

   DNS Suffix Search List. . . . . . : ******

                                       ******

 

Ethernet adapter Ethernet 2:

 

   Media State . . . . . . . . . . . : Media disconnected

   Connection-specific DNS Suffix  . :

   Description . . . . . . . . . . . : PANGP Virtual Ethernet Adapter

   Physical Address. . . . . . . . . : 02-50-41-00-00-01

   DHCP Enabled. . . . . . . . . . . : No

   Autoconfiguration Enabled . . . . : Yes

 

Ethernet adapter Ethernet:

 

   Media State . . . . . . . . . . . : Media disconnected

   Connection-specific DNS Suffix  . : ******

   Description . . . . . . . . . . . : Intel(R) Ethernet Connection (4) I219-LM

   Physical Address. . . . . . . . . : 54-E1-AD-25-FD-00

   DHCP Enabled. . . . . . . . . . . : Yes

   Autoconfiguration Enabled . . . . : Yes

 

Ethernet adapter VirtualBox Host-Only Network:

 

   Connection-specific DNS Suffix  . :

   Description . . . . . . . . . . . : VirtualBox Host-Only Ethernet Adapter

   Physical Address. . . . . . . . . : 0A-00-27-00-00-14

   DHCP Enabled. . . . . . . . . . . : No

   Autoconfiguration Enabled . . . . : Yes

   Link-local IPv6 Address . . . . . : fe80::a46e:62f7:c155:7854%20(Preferred)

   IPv4 Address. . . . . . . . . . . : 192.168.56.1(Preferred)

   Subnet Mask . . . . . . . . . . . : 255.255.255.0

   Default Gateway . . . . . . . . . :

   DHCPv6 IAID . . . . . . . . . . . : 738852903

   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-20-CB-08-63-54-E1-AD-25-FD-00

   DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1

                                       fec0:0:0:ffff::2%1

                                       fec0:0:0:ffff::3%1

   NetBIOS over Tcpip. . . . . . . . : Enabled

 

Wireless LAN adapter Local Area Connection* 2:

 

   Media State . . . . . . . . . . . : Media disconnected

   Connection-specific DNS Suffix  . :

   Description . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter

   Physical Address. . . . . . . . . : 00-28-F8-E7-45-F1

   DHCP Enabled. . . . . . . . . . . : Yes

   Autoconfiguration Enabled . . . . : Yes

 

Wireless LAN adapter Wi-Fi:

 

   Connection-specific DNS Suffix  . : ******

   Description . . . . . . . . . . . : Intel(R) Dual Band Wireless-AC 8265

   Physical Address. . . . . . . . . : 00-28-F8-E7-45-F0

   DHCP Enabled. . . . . . . . . . . : Yes

   Autoconfiguration Enabled . . . . : Yes

   Link-local IPv6 Address . . . . . : fe80::b418:e5c0:f2e2:b1%13(Preferred)

   IPv4 Address. . . . . . . . . . . : ******(Preferred)

   Subnet Mask . . . . . . . . . . . : 255.255.254.0

   Lease Obtained. . . . . . . . . . : Friday, February 2, 2018 3:58:49 PM

   Lease Expires . . . . . . . . . . : Saturday, February 3, 2018 3:58:48 PM

   Default Gateway . . . . . . . . . : ******

   DHCP Server . . . . . . . . . . . : ******

   DHCPv6 IAID . . . . . . . . . . . : 83896568

   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-20-CB-08-63-54-E1-AD-25-FD-00

   DNS Servers . . . . . . . . . . . : ******

   Primary WINS Server . . . . . . . : ******

   NetBIOS over Tcpip. . . . . . . . : Enabled

 

 

 

 

Then check ifconfig on the Virtual PC (Ubuntu in VirtualBox in my case). I can see a new interface are created as shown below.

 

Network configuration on Guest (Ubuntu) after Network Interface Setting

enp0s3    Link encap:Ethernet  HWaddr 08:00:27:d5:84:25  

          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0

          inet6 addr: fe80::5965:c516:1a41:2eeb/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:5 errors:0 dropped:0 overruns:0 frame:0

          TX packets:58 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:1081 (1.0 KB)  TX bytes:6906 (6.9 KB)

 

enp0s8    Link encap:Ethernet  HWaddr 08:00:27:39:57:f8  

          inet addr:10.0.3.15  Bcast:10.0.3.255  Mask:255.255.255.0

          inet6 addr: fe80::3c4d:2117:f3ea:6bcb/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:10 errors:0 dropped:0 overruns:0 frame:0

          TX packets:66 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:1821 (1.8 KB)  TX bytes:7487 (7.4 KB)

 

enp0s9    Link encap:Ethernet  HWaddr 08:00:27:83:57:57  

          inet addr:192.168.56.101  Bcast:192.168.56.255  Mask:255.255.255.0

          inet6 addr: fe80::90ac:c018:d7af:22ac/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:12 errors:0 dropped:0 overruns:0 frame:0

          TX packets:55 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:1799 (1.7 KB)  TX bytes:7023 (7.0 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:44 errors:0 dropped:0 overruns:0 frame:0

          TX packets:44 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:3419 (3.4 KB)  TX bytes:3419 (3.4 KB)

 

 

As a final check, let's try ping between the Host PC and Virtual PC. Following is the result of ping from Host PC to Virtual PC.

 

 

 

Following is the result of ping from Host PC to Virtual PC.

 

 

 

 

Next Step

 

After I completed this step, I installed open-ssh server on my virtual PC (Ubuntu) and then establish SFTP connection between the host PC (Windows PC) and Virtual PC using WinSCP. Then I was able to transfer files back and forth very easily.