Score:2

vBox Server w. Bridged Network Will Only Connect on Home Wifi

tr flag

My debian 10.5 vBox server on ubuntu 20.04 host will not connect to the internet, nor host to guest if I am not on my home wifi network. (vBox 6.1)

I can't ping the server from the host to the server.

Everything boots, correctly, no service failures at boot... (meaning, no error messages to help me troubleshoot.)

I tried switching to a nat network and configuring port forwarding. I was able to ssh into the box, but couldn't ping from host and had no outside internet connection inside the box.

Can someone a complete solution, that allows me to use different wifi networks at will?

My debian 10.5 server has this in the `/etc/notwork/interfaces

auto enp0s3
iface enp0s3 inet static
        address 192.168.0.84  #My server is running a bind DNS server, so I added its address
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255
        gateway 192.168.0.1
        dns-nameservers 192.168.0.84 100.100.2.136 100.100.2.138 8.8.8.8 `

FYI, this an tutorial that solves the same problem, but I couldn't quite "translate" it for Ubuntu Host and Debian 10.5 server https://marcus.4christies.com/2019/01/how-to-create-a-virtualbox-vm-with-a-static-ip-and-internet-access/

PonJar avatar
in flag
Are you saying it works at home but not elsewhere? Have you configured the server for other SSID’s and their corresponding passwords. You will not be able to ping the server when it doesn’t connect to the local network. Ubuntu server uses Netplan, not sure what Debian server uses. I’m guessing Debian server questions are not really allowed here
nightwatch avatar
tr flag
Yeah works at home.. but nowhere else... I am on an ubuntu 20.04 host, so I thought it would be ok... and vbox is installed on the host.
nightwatch avatar
tr flag
I am using a bridged adapter, never configure the server for the SSID and passwords. Ubuntu host assigns everything
PonJar avatar
in flag
Perhaps my memory is playing tricks on me but in bridged mode the VM gets it’s own IP address. I think when I’ve done this in the past I had to configure wpa_supplicant.conf in the VM
in flag
Does the VM need to be accessible to other machines on the network? Or does it only need to be accessed via the host?
nightwatch avatar
tr flag
The host needs to ssh into machine and the machine itself needs outside internet connection. I currently trying NAT and Host-Only adapter combination configs, but I haven't quite got it right.
Score:1
pk flag

Root cause:

Your home network is using the 192.168.0.0/24 network. That means that your devices in the home network have addresses from 192.168.0.1 (your router) to 192.168.0.254.

Another network somewhere else might/will be using another network range.

Your workstation is presumably configured to use DHCP, i.e. it will get an IP address assigned ot of the network's address range, e.g. 192.168.0.100 at home or 192.168.67.45 somewhere else.

Your VM has a fixed IP out of your home network's range and thus can't connect in a network that uses a different range.

When you switch to the NAT network in Virtualbox, then the same applies. The NAT Network on Virtualbox (which is a network BEHIND your physical adapter provided to the VM) is 10.0.2.0/24 as far as I know and the gateway (your workstation) is 10.0.2.2.

Taking this into consideration, there are multiple possible solutions:

Solution 1: use Bridge and DHCP

You don't specify if you need to use a fixed IP address in the VM. If you don't, then change /etc/network/interfaces to

auto enp0s3
iface enp0s3 inet dhcp

Solution 2: use DHCP and NAT

The same config in your guest like above, but with the NAT network

Solution 3: fixed IP on the NAT network

First use Solution 2. Then figure out which IP/Subnet you get assigned then change the config in your /etc/network/interfaces to reflect the changes:

auto enp0s3
iface enp0s3 inet static
        address 10.0.2.84
        netmask 255.255.255.0
        network 10.0.2.0
        broadcast 10.0.2.255
        gateway 10.0.2.2
        dns-nameservers 10.0.2.84 100.100.2.136 100.100.2.138 8.8.8.8 `

You will need to port forward from the outside world to the VM though.

Solution 4: use two network adapters

From your question it is not entirely clear why you are running bind on your VM. I assume you want to use it as a DNS Server for filtering etc in your LAN? If you want to keep your above configuration then just remove the line

gateway 192.168.0.1

and add a second network interface, which might be called enp1s45 for example using dhcp as a gateway to the internet:

auto enp1s45
iface enp1s45 inet dhcp

This way the second interface provides the gateway to the internet. At home your machine will still be 192.168.0.84

nightwatch avatar
tr flag
hey there. thanks for your post. I will test on Tues./Wed. trying to make a deadline. But I will grant you the bounty.. For no other reason, than making a real effort to be helpful. :-) Enjoy Your day!
onemarcfifty avatar
pk flag
Thanks a million - that is very kind of you- let me know if it works!
nightwatch avatar
tr flag
A few days late, as seems to be my "new normal"... but just checking in to confirm that Solution 4 worked brilliantly. I can travel freely, quickly connect and get things done. THANKS!
nightwatch avatar
tr flag
FYI,, it was the gateway condition in my original config that was tripping me up. good catch. PS... I noticed that you are German...
onemarcfifty avatar
pk flag
Awesome, I am glad that it worked !!! And yes, I am German ;-)
nightwatch avatar
tr flag
So I decided to break things again... ;-P Perhaps you have little more German Ingenuity for me :-) https://askubuntu.com/questions/1378968/ufw-unblock-host-to-guest-traffic
Score:0
cn flag

So your home network allows you to connect your main laptop Operating System (Hypervisor) wlan interface to the Wifi, and provides an Ip address, and then when you run the VM (guest) as bridged also provides an additional Ip address, but in other places like Internet cafes this doesn't happen. I would say this is expected behavior in most router configurations. The normal behavior would be that each MAC to get only one Ip after successfully login to the Wifi with credentials (like the laptop's Hypervisor did).

nightwatch avatar
tr flag
thx for the reply. I understand this conceptually, but the above is not an implementable solution to my problem.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.