1

Inside vbox6.1 on an Ubuntu Desktop host. I have a software requirement for a host-only network adapter with internet access. I was able to configure this and I can successfully ping the guest from the host and the guest has internet access via the host-only adapter.

I have one remaining problem, local dns resolution.

In order to get internet access to the guest I had to use ip MASQUERADE from the vboxnet0 address to the primary network interface of the host.

This caused one side effect. Although the guest has a bind9 server configured and runnng correctly, the host machine can only resolve IP address from the guest, not domain names. For example

I can reach the guest's server control panel using:

https://192.168.64.87:3080

But I cannot not reach the server control panel using:

https://test.example.com:3080

The host machine has resolvconf installed, but it seems that ip Masquerade is causing the content of the host machine's /etc/hosts file to skipped / ignored and attempts to directly resolve domains from public dns servers.

when I use dig example.com it shows that the dns of my production server is being utilized to try to resolve test.example.com which doesn't exist on the production server.

How can I force the host's machine's resolvconf (or another tool) to resolve domain names on the guest server so that I can view them in the host's web browser?

Progress Update
My host machine's /etc/resolv.conf has:

nameserver 192.168.61.2
nameserver 127.0.0.1
search hitronhub.home

where 192.168.61.2 is the ip address of the vboxnet0 dhcp server

I have also been some more research and installed dnsmasq as recommended here

Now, when I run dig example.com it does not show my productions nameserver. It doesn't show any nameserver and fails. (I have not fully configured dnsmasq yet)

Any tips appreciated

mjones
  • 317
  • 2
  • 7
  • 21

1 Answers1

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 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 192.168.64.87" >> /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/192.168.64.87" >> /etc/dnsmasq.conf'

NOTE: Folks developing wordpress multisites that need wildcard domain resolution can use:
$ sudo bash -c 'echo "address=/example.test/192.168.64.87" >> /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 192.168.64.87" > /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.

mjones
  • 317
  • 2
  • 7
  • 21