Score:0

Ubuntu 20.04.3 autoinstall Network Issue dhcp

in flag

Currently I have a small ssh network problem. I use an Ubuntu 20.4 Server Edition incl. autoinstall. I removed the network configuration from my user-data file because it should be better for the installation to select the adapters itself. Now I have the problem that after the first reboot my packer script cannot connect to ssh.

Only after entering the command dhclient -r and dhclient the packer script connected successfully with my Ubuntu installation.

user-data File:

#cloud-config
 autoinstall:
  version: 1
  early-commands:
    - systemctl stop ssh
  locale: en_US
  apt:
    geoip: true
  keyboard:
    layout: en
    variant: us
  storage:
    grub:
      reorder_uefi: False
    config:
    - {ptable: gpt, path: /dev/vda, preserve: false, name: '', grub_device: false,
      type: disk, id: disk-vda}
    - {device: disk-vda, size: 536870912, wipe: superblock, flag: boot, number: 1,
      preserve: false, grub_device: true, type: partition, id: partition-vda1}
    - {fstype: fat32, volume: partition-vda1, preserve: false, type: format, id: format-2}
    - {device: disk-vda, size: 1073741824, wipe: superblock, flag: linux, number: 2,
      preserve: false, grub_device: false, type: partition, id: partition-vda2}
    - {fstype: ext4, volume: partition-vda2, preserve: false, type: format, id: format-0}
    - {device: disk-vda, size: -1, flag: linux, number: 3, preserve: false,
      grub_device: false, type: partition, id: partition-vda3}
    - name: vg-0
      devices: [partition-vda3]
      preserve: false
      type: lvm_volgroup
      id: lvm-volgroup-vg-0
    - {name: lv-root, volgroup: lvm-volgroup-vg-0, size: 100%, preserve: false,
      type: lvm_partition, id: lvm-partition-lv-root}
    - {fstype: ext4, volume: lvm-partition-lv-root, preserve: false, type: format,
      id: format-1}
    - {device: format-1, path: /, type: mount, id: mount-2}
    - {device: format-0, path: /boot, type: mount, id: mount-1}
    - {device: format-2, path: /boot/efi, type: mount, id: mount-3}
  identity:
    hostname: ubuntu
    username: ubuntu
    # pass is ubuntu
    password: $6$rounds=4096$8dkK1P/oE$2DGKKt0wLlTVJ7USY.0jN9du8FetmEr51yjPyeiR.zKE3DGFcitNL/nF1l62BLJNR87lQZixObuXYny.Mf17K1
  ssh:
    install-server: yes
  packages:
    - network-manager
    - vim
    - tmux
    - curl
  package_update: true
  package_upgrade: true
  user-data:
    disable_root: false
  late-commands:
    - echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/ubuntu
    # Changing from networkd to NetworkManager
    # move existing config out of the way
    - find /target/etc/netplan/ -name "*.yaml" -exec sh -c 'mv "$1" "$1-orig"' _ {} \;
    # Create a new netplan and enable it
    - |
      cat <<EOF | sudo tee /target/etc/netplan/01-netcfg.yaml
      network:
        version: 2
        renderer: NetworkManager
      EOF
    - curtin in-target --target /target netplan generate
    - curtin in-target --target /target netplan apply
    - curtin in-target --target /target systemctl enable NetworkManager.service
    - dhclient -r
    - sleep 10s
    - dhclient
    - sleep 10s
Johan Palych avatar
us flag
NetworkManager comes with nmcli(man nmcli) and nmtui(man nmtui). nmcli connection show or ls /etc/NetworkManager/system-connections/ then: nmcli c show 'connection' | grep dhcp then: nmcli c modify 'connection'setting.property value. Do not forget to reload the configuration file with nmcli connection reload. https://ubuntu.com/core/docs/networkmanager/edit-connections
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.