Configure static ip on Ubuntu Server 20.04

Follow these simple steps to configure a static IP address on a Ubuntu Server 20.04:

Step 1: Determine the interface that you want to configure with a static ip address

“ifconfig” or “ip” command can be used to determine the interfaces on the system.

$ ifconfig

Step 2: CloudInit

Make sure that the network interface is not managed by the CloudInit.

$ sudo cat /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg

You should see “network: {config: disabled}

Step 3: Backup the existing config file

$ sudo cp 00-installer-config.yaml 00-installer-config.yaml.backup

Step 4: Update the interface configuration

You will notice that the interface configuration is set to “dhcp4 :true“. It should be updated with static configuration. Sample output:

network:
  ethernets:
    enp0s3:
      dhcp4: true
  enp0s8:
    dhcp4: true
  enp0s9:
    dhcp4: true
  version: 2

Sample update for enos08

network:
  ethernets:
    enp0s3:
      dhcp4: true
    enp0s8:
      addresses: [192.168.1.200/24]
      gateway4: 192.168.1.1
      nameservers:
        addresses: [192.168.1.1]
    enp0s9:
      dhcp4: true
  version: 2

Step 5: Make sure there are no syntax errors

Use netplan try command:

$ sudo netplan try

Step 6: Apply Changes

Sample update for enos08

$ sudo netplan apply

Step 7: Reboot

$ sudo reboot

Step 8: Verify

$ ifconfig

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s