0

I'm using Virtual Box on

Linux rubi-pc 4.9.28-1-MANJARO #1 SMP PREEMPT Sun May 14 13:32:39 UTC 2017 x86_64 GNU/Linux

I've 2 VM running Ubuntu 16.04 Server. If I put Host-Only Adapter in Adapter 1 Option in both VMs. I can SSH into both VMs through my terminal. but no internet connection even though I've added NAT as my secondary Adapter.

If I put NAT in both VMs Internet connection working but I Can not SSH into VMs,

ifconfig details of one VM with Host-Only Adapter enabled in Adapter 1 Optiton

ubuntu@ubuntu:~$ ifconfig
enp0s3    Link encap:Ethernet  HWaddr 08:00:27:a5:e7:1c  
          inet addr:192.168.56.103  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fea5:e71c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:102 errors:0 dropped:0 overruns:0 frame:0
          TX packets:109 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:17424 (17.4 KB)  TX bytes:15890 (15.8 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:4960 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4960 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:367040 (367.0 KB)  TX bytes:367040 (367.0 KB)

virbr0    Link encap:Ethernet  HWaddr 52:54:00:4b:78:11  
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Is there anyway that I can fix to work both internet and SSH ?

In a side not, I can not directly use copy paste function to Virtual Machines via local machine.

2 Answers 2

0

If you set up NAT, then typically, you will not be able to login from an outside machine or host into the VM. That is because the NAT is translating the internal IP addresses and access is only possible from the VMs to the outside world (including the internet)

Host only networking creates an isolated network between the host and the VMs so there is no connection to the internet.

You should use a bridged network. Then the host and the VMs will be in the same L2 domain and should get IPs on the same subnet. Check that the default gateway for each VM matches the default gateway of the host. THen you should be able to access the internet from the VMs and login to the VMs as well.

2
  • I've installed Desktop version of Ubuntu 16.04 on Virtual box and put NAT as adapter 1 and Host-only as Adapter 2, now that is working fine, problem with Bridged Network is , my organization require to whitelist MAC address of PC running and need certificate to connect to the network , I assume that'll be a problem with bridge network right ? Commented Jun 2, 2017 at 6:04
  • In that case, you could keep the VMs on a separate bridge and subnet and add routes via the host. This is a more complicated configuration so I would recommend you stick with your working solution.
    – Perennial
    Commented Jun 2, 2017 at 16:06
0

The problem seems to be a missing interface configuration. The way I achieve it here is to find the physical interface name, and add it to the networking configuration.

In the following example, NAT is on the enp0s3 interface. I have added a host-only interface with VirtualBox, on vboxnet0.

# List all available interfaces
> ifconfig -a
ifconfig -a
enp0s3    Link encap:Ethernet  HWaddr 08:00:27:5d:15:e6
          ...
enp0s8    Link encap:Ethernet  HWaddr 08:00:27:4b:24:16
          ...
lo        Link encap:Local Loopback
          ...

# Create an entry for the new interface
> vim /etc/network/interfaces

    # Original
    auto enp0s3
    iface enp0s3 inet dhcp

    # Added (here with VIM)
    auto enp0s8
    iface enp0s8 inet dhcp

# Start the interface
> ifup enp0s8

At this point, the interface should have gotten an IP and be ready. See also this answer on the Unix SE for a related procedure.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .