1

I have the following scenario: I'm on a laptop that I normally use to go from meeting to meeting and in house... I normally use this laptop to present projects and developments.

So as I go from here to there all the time... I decided to find a way to configure my equipment so that with a few clicks I can make my development environments work, etc...

As a first point the specifications of my environments: as host (operating system installed on the hardware) Windows 11 Pro, this computer is connected to a private network using the following settings:

LAN or WLAN configuration (Office, Static) Note: these data were given and configured by the technical department if I change something I lose the internet connection on the office.
enter image description here

Or to private network WLAN (my House, DHCP)
enter image description here

switching between the LAN and WLAN whichever is sharing the internet with the VM workstation Network Device is the dynamic part... whichever should continue to provide the internet connection.

next... I have installed VM Workstation 16 y and I have created a virtual machine with ubuntu 20.04 server.

I explain how I have shared the network:

  1. I have taken the wired network or the wifi network, and shared it to the network device that VM Workstation created.
  2. Whether it is the wired or wifi network that provides internet connectivity is what I need to be dynamic, that is why I am using a static configuration in the adapter that VM Workstation has created:
    enter image description here
  3. In my VM Workstation network device manager I have the following NAT configuration ():
    enter image description here
    enter image description here
    enter image description here
  4. In ubuntu, I am using this configuration:
network:
  version: 2
  renderer: networkd
  ethernets:
    ens33:
      dhcp4: false
      dhcp6: false
      addresses:
        - 192.168.160.135/24
      routes:
        - to: default
          via: 192.168.160.1
      nameservers:
        addresses:
          - 192.168.160.1
          - 192.168.2.2

just in case you think to ask me why use NAT in conjunction with a static IP or subnet? I do this because I usually have the developments in a virtual host, my windows host file looks like this:

192.168.160.135 test1.vm    www.test1.vm
192.168.160.135 test1.vm    www.test1.vm

In this way I get that in a single virtual machine through virtual host I can access and maintain different projects.

The problem is that sometimes it works and other times it doesn't.... for some reason I get a name resolution error.

can someone try to help me with this problem... if i'm configuring something wrong, i'm bad at subnetting.

15
  • I use Virtual Machines (VMware) with NAT access all the time. I wonder if (suspect) your issue come from having your laptop using a static HOST IP. Laptops are best configured using DHCP (and DHCP reservation if need be).
    – anon
    Commented May 16, 2022 at 16:49
  • @John well, the static ip is mandatory to be able to access the physical local network.
    – user1097374
    Commented May 16, 2022 at 16:52
  • Is it just name resolution errors? If you get into that state again, check whether your VM can reach either nameserver like: nslookup google.com 192.168.2.2
    – Cpt.Whale
    Commented May 16, 2022 at 17:07
  • @Cpt.Whale yes only have this error becouse i can join to every dev in VM but VM not have conectivity to Internet... i need execute it on VM nslookup google.com 192.168.2.2??
    – user1097374
    Commented May 16, 2022 at 17:10
  • and if it's correct, sometimes it works and sometimes it doesn't... when I've seen it work when pinging, it indicates that it did it through the gateway...
    – user1097374
    Commented May 16, 2022 at 17:12

1 Answer 1

2

With the help of my colleagues in the comments, I realized that one of the things that was failing was the gateway... somehow, when it came to things, the system worked a couple of times, but after restarting the equipment, the configuration was lost. ... the definitive solution is here:

  1. Any configuration can be used on the host: static or DHCP, the internet must always be shared between the device that has the active network and connectivity on the host with the device created by VMware... the examples used above fit correctly.

  2. It is important to establish the following data since they will be the ones that guarantee our internet connection:

    A. On the windows side in the VMware network device we implement an IP like this: 192.168.XXX.1 then the subnet mask we can leave the default 255.255.255.0 at the moment this does not negatively affect our network.

    B. then we have to verify the settings of our NAT configuration both the device and the internal one is correct:

Device
enter image description here

Internal
enter image description here

  1. Then the configuration that we are going to apply to our Virtualized Operating System must implement the Internal gateway (not the device gateway)and the DNS can be any public DNS.
network:
  version: 2
  renderer: networkd
  ethernets:
    ens33:
      dhcp4: false
      dhcp6: false
      addresses:
        - 192.168.160.135/24
      routes:
        - to: default
          via: 192.168.160.2
      nameservers:
        addresses: [8.8.4.4]

why implement a public DNS?

with this I allow that if I am using shared internet of my wifi or a network other than the one of the office, the name resolution is carried out in the public dns and I am not tied to the DNS of the static configuration of the office

What happens if you disconnect from the wired network and switch to Wi-Fi hot?

momentarily I will lose the connection in the virtual machine; At the moment you are going to share the wireless network automatically the virtual machines will obtain internet connectivity...

This configuration also allows me to implement, a reverse proxy or even virtual host implementation... by editing the Windows Host file... as described in the post above.

I was investigating if there is any free software that allows me to change from one network profile to another in a simpler way, I only found NetSetMan; but this one has no direct option to exchange which device serves the internet to another device through the shared network configuration, what it does accept is a script but I haven't had time to develop it.

You must log in to answer this question.