Tuesday, February 15, 2022

Virtual box gotchas

Virtual box 

  - creates guest OS virtual machines on host operating system (the ones you use enerally) 

By default the resolution of the guest OS will not be same as host os (your actual os). You will need to install Guest additions and switch to Seamless mode after the os is started.

Running VPN within virtual box : 

https://windowsreport.com/vpn-not-working-on-virtualbox/


Open VPN in windows 10 virtual machine with DNS blocked on VPN gateway:

    Context: The Open VPN server on company network was not supporting external DNS resolution . This was probably blocked by admin for security reasons.  The suggested approach was to use dnsmasq which is supported only on mac /linux. But i was on windows 10, hence had to find an alternative. I tried Acryllic DNS proxy client. Basically AcryllicDNS does dns resolution on the local system. 


1. Below is result of DNS resolution with Acryllic DNS running and open VPN off

c:> nslookup google.com 127.0.0.1

C:\Users\sandeep>nslookup google.com 127.0.0.1

Server:  UnKnown

Address:  127.0.0.1

Non-authoritative answer:

Name:    google.com

Addresses:  2a00:1450:4009:81d::200e

          142.250.180.14

You see above the DNS got resolved using Acryllic DNS running on 127.0.0.1

2. Below is result of DNS resolution with Acryllic DNS running and open VPN running

c:> nslookup google.com 127.0.0.1 

C:\Users\sandeep>nslookup google.com 127.0.0.1

DNS request timed out.

    timeout was 2 seconds.

Server:  UnKnown   Address:  127.0.0.1

DNS request timed out.

    timeout was 2 seconds. ...

*** Request to UnKnown timed-out

As you see above the problem with DNS resolution when open VPN is on .

 

Note: By default DNS server of choice was picked from the open VPN  ethernet adapter TAP. This can be switched to use localhost (127.0.0.1) by setting the metric on adapter (Adapter properties >> IpV4 >> Advanced settings >> metric = 5). 


Basic commands

1. To list all the registered VMs: vboxmanage list vms


Network commands on windows :

1. ping -t google.com

2. tracert google.com [8.8.8.8]  ([] is the DNS server to override)

3. route print  ( After tracert we can run this to check the route you amazon packet took ;) )

          4. ipconfig /displaydns  [ /flushdns ]

 



Gotchas:

1. For fixing screen resize one needs to install guest additions plugin for virtual box. Sometimes it doesnt do anything on clicking Device >> Insert guest additions.

Fix : Insert Guest Additions simply inserts a CD. That's it. If your guest supports Autoplay and it is enabled, the installation will start. Otherwise you'll have to start the installation manually. More details on the user manual, ch. 4.2.

Ref: https://forums.virtualbox.org/viewtopic.php?t=86281

2. Coming out of scaled mode : hit right CTRL + C , right CTRL +L to come out of seamless mode

3. Guest doesnt resolve dns when open vpn is connected

VBoxManage modifyvm "<VM name>" --natdnshostresolver1 on

As a result, guest OS DNS requests will be intercepted and resolved using host DNS API, rather than having guest OS connect to external DNS servers as with --natdnsproxy1 on.

Ref: https://superuser.com/questions/641933/how-to-get-virtualbox-vms-to-use-hosts-dns

4. Connecting from mac Guest OS to windows host os (as guest additions was not working):

       1.Shared the windows folder (right click folder >> properties >> share)

        2. ON virtual box VM config, add another adapter 2 called Bridged adapter. This will create a bridged network adapter for which you fix a static ip say 192.168.1.100.

        3. From Mac Guest open Finder (icon in the panel) >> Click Go menu >> Connect to server. Enter Ip 192.168.1.100. Thats it shared folder appears.

          Refer link


References :

No comments: