0

I am running ubuntu on my machine with another ubuntu in Virtualbox, I am trying to make them connect together so they both have access each others and both can access the internet.

This is the ifconfig of the host machine

eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    inet 130.15.1.72  netmask 255.255.255.0  broadcast 130.15.1.255
    inet6 fe80::3f37:1632:b494:f83d  prefixlen 64  scopeid 0x20<link>
    ether 84:2b:2b:a2:f0:d2  txqueuelen 1000  (Ethernet)
    RX packets 7275030  bytes 2419246030 (2.4 GB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 705630  bytes 93740106 (93.7 MB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    device interrupt 21  memory 0xf7fe0000-f8000000  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
    inet 127.0.0.1  netmask 255.0.0.0
    inet6 ::1  prefixlen 128  scopeid 0x10<host>
    loop  txqueuelen 1000  (Local Loopback)
    RX packets 132569  bytes 44162247 (44.1 MB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 132569  bytes 44162247 (44.1 MB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 

And this is the /etc/network/interfaces of the host

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eno1
iface eno1 inet static
address 130.15.1.72
netmask 255.255.255.0
network 130.15.1.0
broadcast 130.15.1.255
gateway 130.15.1.1

In Virtualbox network settings, I set up a Host only network called vboxnet0 with the following settings:

IP4 Address: 192.168.56.0
IP4 Network Mask: 255.255.255.0  

and DHCP disabled

Now I have in the virtual machine settings:

Adapter 1: Host only network - vboxnet0
Adapter 2: NAT

This is the output when I run ls /sys/class/net on my guest

enp0s3 enp0s8 lo

This is the ifconfig of the guest machine

enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.56.101  netmask 255.255.255.0  broadcast 192.168.56.255
        inet6 fe80::a00:27ff:fefd:775c  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:fd:77:5c  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 87  bytes 9096 (9.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.3.15  netmask 255.255.255.0  broadcast 10.0.3.255
        inet6 fe80::a00:27ff:fef3:976  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:f3:09:76  txqueuelen 1000  (Ethernet)
        RX packets 14384  bytes 13692205 (13.6 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6941  bytes 749919 (749.9 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 348  bytes 25732 (25.7 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 348  bytes 25732 (25.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

And this is the /etc/network/interfaces

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

# The host-only network interface
auto enp0s3
iface enp0s3 inet static
address 192.168.56.101
netmask 255.255.255.0
network 192.168.56.0
broadcast 192.168.56.255

# NAT interface
auto enp0s8
iface enp0s8 inet dhcp

I am trying to ping to make sure the connectivity is established. The guest seems to be able to ping the host (130.15.1.72) successfully. However, the host can only ping 192.168.56.0 (which is just the broadcast address for vboxnet0), while pinging 192.168.56.101 just hangs without giving any output. Also, when I try to SSH from the host, I just get

Trying 192.168.56.101...

While when I try to SSH from the guest I get a connection refused error.

Please help me and let me know what I'm doing wrong. I am sure it's something in the IP addresses because it was very confusing for me to set up.

Thanks

1 Answer 1

0

After several days of continuous research, and trial and error. I finally managed to solve the issue, and I can't believe how simple it was...

My problem was solved by simply updating virtualbox to the latest version! I just ran

sudo apt-get update && sudo apt-get upgrade

VirtualBox should be closed before running this command, or else it will fail to update obviously. After this, I just restarted my host machine, and that did it! my ifconfig was automatically fixed to show the new interface (vboxnet0), which I was never able to see before:

eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 130.15.1.72  netmask 255.255.255.0  broadcast 130.15.1.255
        inet6 fe80::862b:2bff:fea2:f0d2  prefixlen 64  scopeid 0x20<link>
        ether 84:2b:2b:a2:f0:d2  txqueuelen 1000  (Ethernet)
        RX packets 45609  bytes 25862185 (25.8 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 16778  bytes 2427180 (2.4 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 21  memory 0xf7fe0000-f8000000  

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 1222  bytes 239666 (239.6 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1222  bytes 239666 (239.6 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vboxnet0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.56.1  netmask 255.255.255.0  broadcast 192.168.56.255
        inet6 fe80::800:27ff:fe00:0  prefixlen 64  scopeid 0x20<link>
        ether 0a:00:27:00:00:00  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 608  bytes 60421 (60.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:43:82:ee  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Now I simply started the guest and sure enough, I was finally able to ping back and forth :) One mistake I was doing though, I thought that (130.15.1.72) should be used to ping the host. That's wrong; the address that was used to setup vboxnet0 in virtualbox network settings should be used by the guests to communicate with the host. Therefore, I set the vboxnet0 settings as follows:

IP4 Address: 192.168.56.1
IP4 Network Mask: 255.255.255.0

All the other settings are left unbranched from my previous post. And now I can ping the host from the guest(s) by:

ping 192.168.56.1 

And I can ping the guests by running

ping 192.168.56.101

Or whatever their static IP is set to be.

Hope this helps anyone else if they got stuck at this, it's really frustrating!

And thanks for whoever read my post

1
  • VirtualBox Version: 5.1.26 r117224 (Qt5.7.1)
    – Omar
    Commented Aug 3, 2017 at 19:41

You must log in to answer this question.

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