TransWikia.com

Ubunutu 20.04: What is the Ubuntu appropriate method of setting a static IP address?

Ask Ubuntu Asked by Not a machine on January 27, 2021

I am losing my mind with a fresh install of server 20.04 on Pi4. There is no desktop on this install. Only a terminal.

I have disabled cloud-init with the following:

echo "network: {config: disabled}" > etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

and then I rebooted and created /etc/netplan/00-installer-config.yaml with a simple static LAN connection on enp0s3.

network:
  ethernets:
    enp0s3:
      addresses: [192.168.1.3/24]
      gateway4: 192.168.1.1
      nameservers:
        addresses: [4.2.2.2, 8.8.8.8]
  version: 2

When I run netplan try it hangs forever. Is there a more 20.04-appropriate, command line method to disable cloud-init and set a static IP address on 20.04? I hate to sound like my father but I am beginning to miss the known and loved (traditional?) network tools on Ubuntu. 🙂

Update:

After reading the docs and a few useful posts I am now doing the following:

sudo apt-get install network-manager

move aside the old cloud yaml file

create a new 10-config.yaml

network:
  version: 2
  renderer: NetworkManager
  ethernets:
    enp3s0:
      addresses: [192.168.1.3/24]
      gateway4: 192.168.1.1
      nameservers:
          addresses: [8.8.8.8, 8.8.4.4]

Then create the templates and apply the configuration:

sudo netplan --debug generate
sudo netplan -d apply           
sudo reboot                       

There are no errors with netplan (now that network manager is installed) but I am unable to login. I can see with nmap (based upon the MAC address) that the device has not changed ip addresses and is still using a dynamic address.

One Answer

This configuration works for me. After running ip link I see that Pi4 uses eth0 rather than enp0s3.

network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses: [192.168.0.50/24]
      gateway4: 192.168.0.100
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]

Followed by:

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

Answered by Not a machine on January 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP