5

After reading this post, I've followed this answer. But , when I edit the /etc/netplan/01-netcfg.yaml, it was blank. So I create that file and add optional: true. After sudo netplan apply, It turns out to be an error error in network definition unknown key 'optional'.

Is the previous post answer still relevant for ubuntu 20.04? And he stated that:

Don't mask or disable the systemd service.

So, what is the best solution for this in 20.04?

edit:
result of ls /etc/netplan

00-installer-config.yaml  01-netcfg.yaml

result of cat /etc/netplan/01-netcfg.yaml

optional: true

result of sudo lshw -C network as @heynnema requested as @heynnema requested and result of cat /etc/netplan/*.yaml
enter image description here

  • Please edit your question to show the result of the terminal command: ls /etc/netplan and also: cat /etc/netplan/01-netcfg.yaml – chili555 Aug 30 '20 at 23:34
  • @chili555 there you go, I've edited it. – Jastria Rahmat Aug 30 '20 at 23:51
  • I order to help you, please edit your question and show me sudo lshw -C network and cat /etc/netplan/*.yaml. Did your Ubuntu Server install fail during the install? – heynnema Aug 31 '20 at 00:21
  • @heynnema I've edited it. No. it didn't fail at all. In VBox, Using NAT is ok, but I want to use bridged adapter now to make it fixed IP. – Jastria Rahmat Aug 31 '20 at 01:26
  • You have two files: 00-installer-config.yaml and 01-netcfg.yaml. We need to consolidate them into one non-conflicting file. May we see both? – chili555 Aug 31 '20 at 02:05
  • @chili555 how?? – Jastria Rahmat Aug 31 '20 at 02:33
  • 2
    I just got this problem too, on a fresh install of Ubuntu Server 20.04. The server has two ethernet ports, and the 'wait' is because only one of them is connected to a network, therefore the second one is waiting for DHCP to occur for up to the two minute time limit. The answer from @heynnema below sorted this for me, i.e. I just added the optional: true setting for the unused ethernet port, ran 'netplan generate' and 'netplan apply', rebooted, and the long wait is now gone. – redcalx Feb 14 '21 at 16:24

1 Answers1

5

In /etc/netplan:

sudo rm -i /etc/netplan/01-netcfg.yaml # remove unnecessary file

sudo -H gedit /etc/netplan/00-installer-config.yaml # edit this file with these contents:

For dhcp:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: true
      optional: true

For static IP: (bridged network)

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      addresses:
        - 192.168.x.xxx/24
      gateway4: 192.168.x.1
      nameservers:
        search: [mydomain, otherdomain]
        addresses: [8.8.8.8, 8.8.4.4]
      optional: true

Create /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

sudo -H gedit /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

with the following content:

network: {config: disabled}

Then:

sudo netplan generate

sudo netplan apply

reboot

heynnema
  • 70,711