1

Situation:
I have Ubuntu 20.04 server inside Vbox6.1 with an Ubuntu 20.04 Desktop Host. Host-Guest communications are configured correctly using vboxnet0 adapter. I can readily ping the static ip of the guest from the host's command line.

Problem:
I recently install a server control panel on the guest and oddly enough, I can only reach access the server control from my host's web browser only using the ip address, not its domain name. For exmaple:

https://192.168.62.87:3080 correctly displays control panel, whereas
https://example.com:3080 has Firefox's "Hmm. We’re having trouble finding that site." error message.

Solutions that I have tried:

1.) First, I tried the obvious. I edited my /etc/hosts file to have
192.168.62.87 example.com didn't work

2.) Next, I tried installing avahi-daemon on the guest server as follows:
sudo apt-get install avahi-daemon & rebooted the guest <-didn't work

Does anyone know how I can get my vbox domain names visible to my host? thanks

Update @Gaétan RYCKEBOER Advice below, revealed something useful.

when I ran dig example.com it revealed that my host is trying to resolve example.com using my PROD server's nameserver, which means of course the control panel will not load because **test**.example.com doesn't exist on y prod server.

It seems that 192.168.62.87 example.com in my /etc/hosts file is being ignored.

This is what I need to correct.
NOTE: my ubuntu test server does have bind9 installed and it is running correctly.

Maestro223
  • 163
  • 1
  • 9
  • adm8n pabels are offtopic – djdomi Jan 22 '22 at 08:57
  • @djdomi I would think that would be irrelevant in the current circumstance as the control panel could have been index.html of any website. Correct domain resolution was obviously the goal – Maestro223 Jan 22 '22 at 09:10

3 Answers3

1

I cannot comment, but:

  • install dns-utils
  • use dig to validate the name resolution: dig example.com
  • try a ping example.com

If everything works, your DNS is working well. Let’s try a https chain debug and investigate the http server logs. For example, your WEB browser may use a proxy, and forward DNS request to the proxy connection.

1

I found a solution. The key thing here was to correctly configure dnsmasq to recognize the ip of my vbox guest's static ip for domain resolution.

I found clear tutorial here, but I made some small modifications, so I will show my steps below for others to follow.

  1. Disable & stop systemd resolved

    $ sudo systemctl disable systemd-resolved
    $ sudo systemctl stop systemd-resolved

  2. Remove symlink on /etc/resolv.conf & remove the file

    $ ls -lh /etc/resolv.conf $ sudo rm /etc/resolv.conf

  3. Create a new /etc/resolv.conf with the following values:

    $ sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolv.conf' #(host machine resolution of doman names)

    $ sudo bash -c 'echo "nameserver 1.1.1.1" >> /etc/resolv.conf' #(public dns server ip for outside internet)

    $ sudo bash -c 'echo "nameserver your-guest's-static-ip address" >> /etc/resolv.conf' #(virtualbox guest static ip address)

  4. Install dnsmasq

    $ sudo apt install dnsmasq

  5. Add .test to the dnsmasq config file:

    $ sudo bash -c 'echo "address=/.test/your-guest's-static-ip address" >> /etc/dnsmasq.conf'

NOTE: Folks developing wordpress multisites that need wildcard domain resolution can use:
$ sudo bash -c 'echo "address=/example.test/your-guest's-static-ip address" >> /etc/dnsmasq.conf'

  1. Create a directory resolver for the guest's static ip address:

    $sudo mkdir -v /etc/resolver && sudo bash -c 'echo "nameserver your-guest's-static-ip address" > /etc/resolver/test'

  2. Restart dnsmasq and network-manager

    $ sudo systemctl restart dnsmasq $ sudo systemctl restart network-manager

  3. Test your dnsmasq set-up

a.) open your browser and confirm that you still have outside internet access

b.) run dig example.test you should be able to seethe static ip address of your guest

c.) in your host machine's browser open example.test

That's it.

Maestro223
  • 163
  • 1
  • 9
0

Your guest should have a server certificate with example.com inside the Subject alternative names extension

J.M. Robles
  • 865
  • 6
  • 9
  • @j-m-robles thanks for your reply.. might you expand a little. I am quite new to local web server dev model. – Maestro223 Jan 19 '22 at 07:30
  • The URL you have mentioned is https. HTTPS implies a dialog between server and client in which the server offers his certificate and the client accepts or not depending on some conditions (validity, trust, ...). One of that conditions it that the certificate must contain the name (in https://name/xxx) in the field Subject Alternative Names. – J.M. Robles Jan 19 '22 at 07:55
  • I updated the post. It seems to be more of a DNS problem rather than SSL – Maestro223 Jan 19 '22 at 09:14