0

I need to provide OVA with static IP.

I'm using clean Ubuntu 18.04 image and running (testing) on virtual box and vmware.

When I configure the IP address in the yaml file, and running the command:

sudo netplan apply  

Nothing changes.

Only when I reboot the machine, the IP address changes.

This is what inside my yaml:

network:
  version: 2 
  renderer:
  ethernets:
    enp0s3:
      dhcp4: no
      addresses: [10.0.2.100/24]
      gateway4: 10.0.2.1
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]

Typically, Linux does not require rebooting. Please help me.

@heynnema

  • @heynnema Can you help me? – Nimitack Dec 20 '18 at 10:34
  • FYI: change rederer: to renderer: networkd. – heynnema Dec 21 '18 at 15:46
  • FYI #2: use sudo netplan -debug generate before sudo netplan apply. – heynnema Dec 21 '18 at 15:47
1

I had the same issue with my machine. It was an issue with the renderer, it is documented that Ubuntu server should come with netwoekd but in my machine (Ubuntu Server 18.04) the network manager that installed is network-manager so I changed the renderer to NetworkManager and it started to work again.

You can check if network-manager is installed by sudo service network-manager status.

I still don't know why network-manager is installed instead of networkd but at least it is working for me now.

0

See if the ip command will help...

Bring interfaces up or down

Previously users were used to using the ifconfig command. Users should now familiarize themselves with the more powerful ip command. Manually modifying network devices is now accomplished via the ip command.

As an example to bring up an interface and bring it back down:

ip link set enp0s3 up
ip link set enp0s3 down

See "man ip" for more information on how to manipulate the state of routing, network devices, interfaces and tunnels.

source: https://netplan.io/faq

  • The interface goes to down/up, but IP doesn’t change. – Nimitack Dec 23 '18 at 8:27
  • You might look at ip address { add | change | replace } IFADDR dev IFNAME, and other ip address commands. – heynnema Dec 23 '18 at 15:12
0

Check that your yaml file in the /etc/netplan/ directory has the highest number preceding the rest of the filename. The Highest number is processed last, and overrides any previous config. Eg. 50-cloud-config.yaml will be processed first, followed by 60-my-new-config.yaml. If 60-my-new-config.yaml reconfigures a device that was listed in the earlier file, then the later config will be applied.

Note too, that if you configured a device in an earlier file, and don't reconfigure it in the later file, then the original device will still be present. This could cause a conflict with your attempt to assign a static IP (eg. device enp0s3 is referenced in a bridge or bond previously, and then the new config cannot be applied).

To check for errors, run the generate command with "--debug" (two dashes not one, as in the comments):

sudo netplan --debug generate

If there is a problem with the script, it will be listed for you to correct. Otherwise, running apply will not make anything change (although your script looks fine - the default renderer is "networkd" if nothing else is specified).

Then apply using the try command, to roll back if there is an error:

sudo netplan --debug try

Check results with the networkctl and/or ip command to see what you got.

sudo networkctl status enp0s3
sudo ip address show enp0s3

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.