Skip to content

Instantly share code, notes, and snippets.

@ohidurbappy
Last active March 8, 2024 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohidurbappy/7596e6d89b4e8004247d827d7d6d5e7a to your computer and use it in GitHub Desktop.
Save ohidurbappy/7596e6d89b4e8004247d827d7d6d5e7a to your computer and use it in GitHub Desktop.
static ip on ubuntu server 2022

go to /etc/netplan

List the files and open the cloud init file, in my case it is 50-cloud-init.yaml

network:
    ethernets:
        eth0:
            dhcp4: false
            addresses: [192.168.0.200/16]
            routes:
                - to: default
                  via: 192.168.10.1
            nameservers:
              addresses: [8.8.8.8,8.8.4.4,192.168.0.1]
#            optional: true
    version: 2

gateway4: 192.168.0.1 is deprecated

then run

sudo netplan apply

alternatively if you have any issue

sudo netplan --debug apply
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment