Prime Stake Pool
WebsiteTwitterTelegram
  • Home
  • About Us
  • Server Setup Basics
    • How to setup your Cloud Server securely
      • Create new user
      • Use ssh key pair to access your server
        • Create .ssh folder
        • Create rsa key pair (public/private)
        • Copy rsa public key to remote server
      • Disable root login,password and change default port 22
      • Install fail2ban
      • Firewall rules
      • Enable 2FA
      • Setup video
    • Linux Swap Space
      • Add Swap Space
      • Kernel cache pressure and swappiness
      • Add swap video
  • Server Settings
    • Setting Up chrony
    • Static IP using Netplan
    • Time Synchronization
    • Important Settings
    • TMUX
  • Linux Commands
    • Basic Commands
    • Important Uses
  • Node Setup Guide
    • Cardano
      • How to minimize missed slot leader checks / missed blocks
        • Garbage collection
        • Run node in multicore mode
        • Turn off TraceMempool
    • Ethereum
  • Monitoring
    • Raspberry Pi ARM
    • Linux System x64
  • Maintenance
  • Logical Volume Management (LVM)
    • Basic concepts
    • LVM Resize
      • Decrease an LVM partition
      • Increase an LVM partition
    • Add a new PV to VG
    • LVM Commands
    • LVM on Pi
  • Disk Check
  • Backup Disk
Powered by GitBook
On this page
  1. Server Settings

Static IP using Netplan

How to setup static IP using netplan on ubuntu 22.04 and above

Setting a static IP address on Ubuntu 22.04 and higher using netplan

Netplan basically acts as a translation layer, it takes configuration files, and creates the right systemd-networkd or Networkmanager configuration.

First disable the cloud-init networking.

Create a file, sudo nano /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following contents:

network: {config: disabled}

Then, edit the existing netplan configuration file, for me this was sudo nano /etc/netplan/50-cloud-init.yaml, which originally looked like this:

network:
    ethernets:
        enp1s0:
            dhcp4: true
    version: 2
    wifis: {}

What it’s basically doing is setting the network interface enp1s0 to use DHCP (and is not static).

Change it to make it look like this:

network:
    ethernets:
        enp1s0:
            dhcp4: false
            dhcp6: false
            addresses:
              - 192.168.50.111/24
            routes:
              - to: default
                via: 192.168.50.1
            nameservers:
                addresses: [1.1.1.1, 8.8.8.8]
    version: 2
    wifis: {}

  • dhcp4: false and dhcp6: false are disabling DHCP for both IPv4 and IPv6.

  • addresses is setting the static IP address.

  • routes is setting the default gateway and pointing at my router, 192.168.50.1

  • nameservers is setting the DNS servers to use, I’ve chosen one Cloudflare and one Google DNS.

Apply changes using:

sudo netplan apply

Check status using:

sudo netplan status enp1s0
PreviousSetting Up chronyNextTime Synchronization

Last updated 6 months ago