Score:1

Enable Host Guest Domain Resuloution

cn flag

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.

djdomi avatar
za flag
adm8n pabels are offtopic
Maestro223 avatar
cn flag
@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
Score:1
it flag

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.

Maestro223 avatar
cn flag
thanks for the feedback.. I updated the post based on what I discovered.
Gaétan RYCKEBOER avatar
it flag
and… what did the ping ? Because dig _always_ performs DNS query. Try "grep hosts /etc/nsswitch.conf --> hosts: files dns" in this order to check /etc/hosts file before, and try global resolver "host example.com"
Maestro223 avatar
cn flag
your feedback about using dig, led me down the right path. I found a solution. Install / config dnsmasq, see below. Thanks again
Gaétan RYCKEBOER avatar
it flag
If so, feel free to upvote :)
Maestro223 avatar
cn flag
There ya. go.. :-)
Score:1
cn flag

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.

Score:0
cn flag

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

Maestro223 avatar
cn flag
@j-m-robles thanks for your reply.. might you expand a little. I am quite new to local web server dev model.
J.M. Robles avatar
cn flag
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.
Maestro223 avatar
cn flag
I updated the post. It seems to be more of a DNS problem rather than SSL
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.