I am running an Ubuntu Server on my VMBox and need to set static IP. By following the steps described in https://www.techrepublic.com/article/how-to-configure-a-static-ip-address-in-ubuntu-server-18-04/, I created the configuration file 01-netcfg.yaml as follows.
network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: no
addresses: [10.10.21.8/24]
gateway4: 10.10.21.100
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
Running sudo netplan apply --debug
results in:
Which I'm not sure if the process is succesful or not since it mentions a merged config but gives no error at the end. However, I can not connect to Internet. sudo ping www.facebook.com
returns "Temporary failure in name resolution". ping 64.233.169.104
results in "Destination Host Unreachable". sudo apt-get update
fails as well.
sudo lshw -C network:
cat /etc/netplan/*
After trying the answer.
cat /etc/resolv.conf
ls -al /etc/resolv.conf
ls -al /etc/netplan
sudo netplan generate --debug
sudo netplan apply
No output.
systemd-resolve --status
Partial answer...
From the comments...
In
/etc/netplan
we have three files...cd /etc/netplan
# change directoriessudo mv 50-cloud-init.yaml 50-cloud-init.yaml.HOLD
# rename filesudo mv 99-disable-network-config.cfg 99-disable-network-config.cfg.HOLD
# rename filesudo netplan --debug generate
# generate config filessudo netplan apply
# apply new configurationNote: The new configuration may already work at this point.
reboot
# confirm operationUpdate #1:
The 10.10.21.8 and 10.10.21.100 addresses are not correct. Go back to your instructor and get valid addresses, and then it should all work now. This all works when using
dhcp4: true
instead of static IP's.After hours of trying suggestions with no success and since I was also having this issue with a VM machine I was able to finally do an apt-get update/upgrade by just creating another VM NIC on the VM settings. Ubuntu Server 18.04 reconigzed it right away and configured the new NIC with DHCP. Apt-get was able to connect to repositories, download and upgrade the install. I then turned off the Ubuntu VM, removed the secondary NIC form its settings and was able to use Apt-get and ping google.com after rebooting using only the original NIC. My static IP settings did not changed.