how to change ip address of ubuntu server 24.04 to static ip

To configure a static IP address on Ubuntu Server 24.04, you’ll need to modify the Netplan configuration file. Here’s how to do it:

  1. First, identify your network interface name:
ip a
  1. Create or edit the Netplan configuration file: (there might be a different file name too, like 50-cloud-init.yaml) or whatever is avaialble, i will be using below
sudo nano /etc/netplan/00-installer-config.yaml
  1. Configure the file with your static IP information:
network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s18:  # Replace with your interface name
      dhcp4: false
      addresses:
        - 10.11.12.7/24  # Your desired static IP/subnet mask
      routes:
        - to: default
          via: 10.11.12.1  # Your gateway IP
      nameservers:
        addresses: [10.11.12.1, 1.1.1.1]  # DNS servers
  1. Apply the configuration:
sudo netplan apply
  1. Verify the new IP address:
ip a

Make sure to replace:

  • enp0s18 with your actual interface name
  • 10.11.12.7/24 with your desired IP address and subnet mask
  • 10.11.12.1 with your gateway address
  • DNS servers as needed for your network

If you encounter any issues, you can check the configuration with:

sudo netplan --debug apply

Leave a Comment