1

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 --debugresults in:

debug

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:

enter image description here

 cat /etc/netplan/*

enter image description here

After trying the answer.

cat /etc/resolv.conf

enter image description here

ls -al /etc/resolv.conf

enter image description here

ls -al /etc/netplan

enter image description here

sudo netplan generate --debug

enter image description here

sudo netplan apply 

No output.

systemd-resolve --status

enter image description here

  • Do you actually have a enp0s3 interface? what is the output of ls /sys/class/net? – steeldriver Apr 5 at 22:37
  • 1
    Do you have more than one .yaml file in /etc/netplan? Edit your question and show me sudo lshw -C network. Amongst other things, I want to see the name of your ethernet device. You should be using sudo netplan --debug generate first, and then sudo netplan apply, then reboot to confirm operation. – heynnema Apr 5 at 22:49
  • @steeldriver the output is "enp0s3" and "lo" – codemonkey Apr 6 at 7:45
  • @heynnema there is also 50-cloud-init.yaml and 99-disable-network-config.cfg files, and i updated the question with "sudo lshw -C " – codemonkey Apr 6 at 8:11
  • Ah! Edit your question and show me cat /etc/netplan/*. Then do you have 3 files in /etc/netplan? 2 .yaml and 1 .cfg? – heynnema Apr 6 at 10:35
1

Partial answer...

From the comments...

In /etc/netplan we have three files...

01-network-card.yaml          # the file that you created
50-cloud-init.yaml            # the file that was already there
99-disable-network-config.cfg # who knows where this file came from

cd /etc/netplan # change directories

sudo mv 50-cloud-init.yaml 50-cloud-init.yaml.HOLD # rename file

sudo mv 99-disable-network-config.cfg 99-disable-network-config.cfg.HOLD # rename file

sudo netplan --debug generate # generate config files

sudo netplan apply # apply new configuration

Note: The new configuration may already work at this point.

reboot # confirm operation

Update #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.

  • Unfortunately, i can't connect the internet after these steps. BTW, I created the 99-disable-network-config.cfg as well. – codemonkey Apr 6 at 11:56
  • But your ping commands failed before, so you were not able to connect to the Internet then either, correct? Edit your question and show me ls -al /etc/netplan and the output of the two sudo netplan... commands... and resolvectl. – heynnema Apr 6 at 12:00
  • And also ls -al /etc/resolv.conf and cat /etc/resolv.conf. – heynnema Apr 6 at 12:03
  • I edited the question. resolvectl command is not found. – codemonkey Apr 6 at 12:17
  • 1
    Ah again! Those IP's are wrong. Unless they've setup those specific IP's somewhere on the network, your .yaml file, although syntactically correct, will never work, and pings and Internet will fail. So this situation is not in a production environment, but rather a college/university environment? I think that with the exception of your symlink for /etc/resolv.conf, I think we've gone as far as we can. Temporarily use dhcp4: true until you get the correct IP's. Please do come back later and update me, and accept my answer when it's all working, ok? – heynnema Apr 6 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.