Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save devantler/6d8bea11f73cc80d00be1502a9437ff0 to your computer and use it in GitHub Desktop.
Save devantler/6d8bea11f73cc80d00be1502a9437ff0 to your computer and use it in GitHub Desktop.
How to add a static IP in Ubuntu 22.04 Server

How to add a static IP in Ubuntu 22.04 Server

Edit the netplan configuration:

sudo nano /etc/netplan/01-netcfg.yaml

Insert the following:

network:
    version: 2
    renderer: networkd
    ethernets:
        eth0:
            addresses:
                - 10.10.10.1/24
            nameservers:
                addresses: [1.1.1.1, 8.8.8.8]
            routes:
                - to: default
                  via: 10.10.1.1

Run the following command to enable the new static IP (no restart needed):

sudo netplan apply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment