ok, my file is located at /etc/netplan/50-cloud-init.yaml I changed the IP address as a static IP address as following:

network:
  version: 2 

  renderer: netwokrd

  ethernets:

    dhcp4: no
    dhcp6: no
    addresses: [10.0.2.100/24]
    gateway4: 10.0.2.1
    nameservers:
       addresses: [10.0.2.100]

Then, I typed sudo netplan apply, and there was not any error message. BUT, when I typed ifconfig, it still remail past IP address on enp0s3. Do you guys know why this happen?

Netplan is fussy about how .yaml files are formatted. Don't try to "pretty-fy" them.

Is 50-cloud-init.yaml the only .yaml file in /etc/netplan? If so, I'd rename it to 01-config.yaml or 01-networkd.yaml.

So edit your .yaml file to look like this...

network:
  version: 2 
  renderer: networkd <-- note the correct spelling
  ethernets:
    enp0s3: <-- identify the proper interface
      dhcp4: no
      dhcp6: no
      addresses: [10.0.2.100/24]
      gateway4: 10.0.2.1
      nameservers:
        addresses: [10.0.2.100] <-- this is probably the wrong address
        addresses: [8.8.8.8, 8.8.4.4] <-- use something like this instead

then do:

sudo netplan --debug generate # generate the config files
sudo netplan apply            # apply the new configuration
reboot                        # reboot the computer

and recheck your ifconfig output.

Note: if it was me, I'd let NetworkManager manage this interface, and set the static address information into the "Wired Connection" profile.

network:
  version: 2
  renderer: NetworkManager

then do:

sudo netplan --debug generate # generate the config files
sudo netplan apply            # apply the new configuration
reboot                        # reboot the computer
  • since the netplan config is in /etc/netplan/50-cloud-init.yaml it is likely this is a cloud image which has no NetworkManager installed. – slangasek Oct 25 at 5:20

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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