Ubuntu 18.04 cloud image does not get DHCP IPv4 address

7,162

I've experienced the same problem on my RasPi 2 install of Ubuntu Server 18.04 LTS (armhf).

dhclient fixes the problem temporarily, but rebooting the system disables IPv4 again.

I will add this... I was able to enable a work-around by adding the following cronjob to start dhclient at boot:

@reboot /bin/sh dhclient
Share:
7,162

Related videos on Youtube

Benjamin Drung
Author by

Benjamin Drung

I am a Debian and Ubuntu developer.

Updated on September 18, 2022

Comments

  • Benjamin Drung
    Benjamin Drung over 1 year

    I am testing the Ubuntu 18.04 LTS cloud image (20180426.2) on a KVM host. There is a DHCP v4 server running, but IPv6 is not supported. When booting the cloud image, it wont get an IPv4 address. The service systemd-networkd-wait-online failed to start:

    root@ubuntu:~# systemctl status systemd-networkd-wait-online.service
    ● systemd-networkd-wait-online.service - Wait for Network to be Configured
       Loaded: loaded (/lib/systemd/system/systemd-networkd-wait-online.service; enabled; vendor preset: enabled)
       Active: failed (Result: exit-code) since Mon 2018-04-30 11:08:47 UTC; 12min ago
         Docs: man:systemd-networkd-wait-online.service(8)
      Process: 669 ExecStart=/lib/systemd/systemd-networkd-wait-online (code=exited, status=1/FAILURE)
     Main PID: 669 (code=exited, status=1/FAILURE)
    
    Apr 30 11:06:47 ubuntu systemd[1]: Starting Wait for Network to be Configured...
    Apr 30 11:08:47 ubuntu systemd-networkd-wait-online[669]: Event loop failed: Connection timed out
    Apr 30 11:08:47 ubuntu systemd[1]: systemd-networkd-wait-online.service: Main process exited, code=exited, status=1/FAILURE
    Apr 30 11:08:47 ubuntu systemd[1]: systemd-networkd-wait-online.service: Failed with result 'exit-code'.
    Apr 30 11:08:47 ubuntu systemd[1]: Failed to start Wait for Network to be Configured.
    

    systemd-network did not bring up IPv4:

    root@ubuntu:~# journalctl -u systemd-networkd
    [...]
    -- Reboot --
    Apr 30 11:06:47 ubuntu systemd[1]: Starting Network Service...
    Apr 30 11:06:47 ubuntu systemd-networkd[651]: Enumeration completed
    Apr 30 11:06:47 ubuntu systemd[1]: Started Network Service.
    Apr 30 11:06:47 ubuntu systemd-networkd[651]: lo: Link is not managed by us
    Apr 30 11:06:47 ubuntu systemd-networkd[651]: ens6: IPv6 successfully enabled
    Apr 30 11:06:47 ubuntu systemd-networkd[651]: ens6: Gained carrier
    Apr 30 11:06:49 ubuntu systemd-networkd[651]: ens6: Gained IPv6LL
    
    root@ubuntu:~# networkctl status ens6
    ● 2: ens6
           Link File: /run/systemd/network/10-netplan-ens6.link
        Network File: /run/systemd/network/10-netplan-ens6.network
                Type: ether
               State: degraded (configuring)
              Driver: virtio_net
              Vendor: Red Hat, Inc.
               Model: Virtio network device
          HW Address: 02:01:a5:2e:fe:bf
             Address: fe80::1:a5ff:fe2e:febf
    

    But DHCP v4 is configured:

    root@ubuntu:~# cat /etc/netplan/50-cloud-init.yaml 
    # This file is generated from information provided by
    # the datasource.  Changes to it will not persist across an instance.
    # To disable cloud-init's network configuration capabilities, write a file
    # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
    # network: {config: disabled}
    network:
        version: 2
        ethernets:
            ens6:
                dhcp4: true
                match:
                    macaddress: 02:01:a5:2e:fe:bf
                set-name: ens6
    root@ubuntu:~# cat /run/systemd/network/10-netplan-ens6.link
    [Match]
    MACAddress=02:01:a5:2e:fe:bf
    
    [Link]
    Name=ens6
    WakeOnLan=off
    root@ubuntu:~# cat /run/systemd/network/10-netplan-ens6.network 
    [Match]
    MACAddress=02:01:a5:2e:fe:bf
    Name=ens6
    
    [Network]
    DHCP=ipv4
    
    [DHCP]
    UseMTU=true
    RouteMetric=100
    

    When I launch dhclient manually, the network device gets an IPv4 address and is reachable (as expected):

    root@ubuntu:~# dhclient
    root@ubuntu:~# networkctl status ens6
    ● 2: ens6
           Link File: /run/systemd/network/10-netplan-ens6.link
        Network File: /run/systemd/network/10-netplan-ens6.network
                Type: ether
               State: routable (configuring)
                Path: pci-0000:00:06.0
              Driver: virtio_net
              Vendor: Red Hat, Inc.
               Model: Virtio network device
          HW Address: 02:01:a5:2e:fe:bf
             Address: 87.106.172.51
                      fe80::1:a5ff:fe2e:febf
             Gateway: 87.106.172.1
    

    Does anybody know why systemd-networkd does not bring up IPv4 correctly? Is that a bug that I should report (against systemd-networkd)?

    • James Addison
      James Addison almost 6 years
      I'm seeing this as well on a DIY machine at home. Used the 18.04 server ISO to create a bootable USB install disc and installed the system with. It got an IP for the first for reboots, then it stopped getting them. dhclient works, but loses again on reboot.
    • Benjamin Drung
      Benjamin Drung almost 6 years
      I created an bug report against systemd: bugs.launchpad.net/ubuntu/+source/systemd/+bug/1779721
  • Elder Geek
    Elder Geek almost 6 years
    Welcome to AskUbuntu! If you have the same problem, you can favorite this question by clicking the star next to it and you'll get notified of new answers. If you have a different question you should ask. Please reserve the answer box for actual answers.