Score:0

Why can't I access the internet when using static ip in a vm? (Netplan)

id flag

I'm trying to configure a network like this using VMs:

network plan picture

For this I have to configure a NatNetwork in virtualbox. Here is the configuration:

NatNetwork config

As you can see DHCP support is unmarked.

Now. I try to configure the first PC (Ubuntu Desktop) using the following configuration of netplan:

netplan not working

I do sudo netplan update annnnd...

interrogation sign

As you can see the internet is unreachable and it shows wired connected with an interrogation sign.

Here is an image showing that the changes applied correctly:

network tests1

Now... I change dhcp in netplan from no to yes...

new netplan config

sudo netplan apply ... and suddenly:

internet working

Everything works for some reason. Can access the internet normally.

Here are the same tests I did before and you'll see that everything is literally the same.

network test 2

I don't understand why it works when DHCP is enabled and it does not when disabled. Considering the natnetwork does not even support DHCP.

Can someone help me?

muru avatar
us flag
Please don't post screenshots of text. Copy the text here and use code formatting instead: https://askubuntu.com/editing-help#code
N0rbert avatar
zw flag
Check https://www.virtualbox.org/manual/UserManual.html#networkingdetails .
Score:1
cn flag

I see while you are making it static still it does ping its gateway, So, most probably of the issue is cause of DNS, set the DNS also.

echo 'nameserver 8.8.8.8' > /etc/resolv.conf

In case you want to add DNS in netplan:

> nameservers:
>         addresses:
>         - 8.8.8.8
>         - 1.0.0.1
user10489 avatar
in flag
It would be better to do this in netplan, since that is what is being used. Editing resolv.conf directly will be a temporary solution at best.
zabiullah avatar
cn flag
No it is not temporary! if you still wants to add to netplan then you can add there too.
us flag
NetworkManager has connectivity checks beyond up routing, which include a dependency on DNS. The original config had no DNS, and DHCP servers almost always provide DNS, so yes this is quite likely to be the issue
user10489 avatar
in flag
Multiple things including NetworkManager step on resolve.conf, so changes there will eventually be blanked if they are not added to netplan.
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.