Skip to content
Follow
Ubuntu Linux

How to Set Up a Static IP on Ubuntu 24.04

Richard
Written by
Richard
Feb 27, 2025 Updated Aug 13, 2026 3 min read
How to Set Up a Static IP on Ubuntu 24.04
How to Set Up a Static IP on Ubuntu 24.04

A static IP address on Ubuntu 24.04 gives your computer a permanent network address that never changes, unlike the temporary ones assigned automatically by routers. This fixed setup stops your IP from shifting, which helps when you run a home server, share files, or connect to network printers.

Ubuntu 24.04 handles network settings through a tool called Netplan. You edit a plain text configuration file in the /etc/netplan/ folder to lock in your IP address details and keep your network connection steady.

⚡ Quick Answer

You set up a static IP on Ubuntu 24.04 by disabling the default Netplan configuration, creating a new YAML file with your IP details, and then applying the changes. Use `sudo mv` to disable the old config, `sudo nano` to create the new one, and `sudo netplan apply` to activate it.

Setup static IP

Setting up a static IP on Ubuntu 24.04 gives your computer a permanent network address that won’t change. This is useful so other devices on your network can always find your computer easily. To do this, you’ll need to change your network settings and turn off Ubuntu’s automatic network setup.

Ubuntu will also come with a default network config YAML file for your device containing automatically generated information that is not persistent.

⚠️Warning
You will need to disable this config to set up your static IP.
⚠️Warning
Run the command below to rename and disable the default config file.
🐧Bash / Shell
sudo mv /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml.bak

Next, run the command below to create a new network configuration file.

🐧Bash / Shell
sudo nano /etc/netplan/01-netcfg.yaml

Then, enter the following network configuration details to use a static IP address for your device.

💻Code
network:
ethernets:
ens33:
dhcp4: false
addresses: [192.168.156.130/24]
routes:
- to: default
via: 192.168.156.2
metric: 100
nameservers:
addresses: [192.168.156.2,192.168.156.3]
search: [srv1.example.com,svr1.geek.net]
dhcp6: false
version: 2

Save and exit.

Descriptions:

  • ens33: ==> interface name. (Yours might be different than mine)
  • addresses: ==> IP address and network mask
  • routes: ==> default gateway
    • [metric]: set priority (specify it if multiple NICs available)
    • lower value is higher priority
  • nameservers: ==> DNS server addresses
  • search: ==> DNS search base

Next, adjust the permissions to protect the file and apply your settings.

🐧Bash / Shell
sudo chmod 600 /etc/netplan/01-netcfg.yaml
sudo netplan apply

Display IP address

After setting up your static IP on Ubuntu 24.04, you can easily check if it's working using the terminal. Simply type the command 'ip address show' to see your computer's current network details. This command will display your new, permanent IP address, confirming your static IP setup is complete.

💻Code
ip address show

The command should output something similar to the one below.

💻Code
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host noprefixroute
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:bc:b2:46 brd ff:ff:ff:ff:ff:ff
altname enp2s1
inet 192.168.156.130/24 brd 192.168.156.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:febc:b246/64 scope link
valid_lft forever preferred_lft forever

That should do it!

Conclusion:

Setting up a static IP address on Ubuntu 24.04 ensures a stable network configuration for essential devices. You can effectively manage your server's connectivity by following the outlined steps. Here are some key takeaways:

  • A static IP address, such as servers and printers, is crucial for devices requiring consistent network presence.
  • Modifying network configurations on Ubuntu server involves editing the YAML file under /etc/netplan/.
  • Always back up the default configuration file before making changes.
  • Adjusting file permissions and applying the settings ensures security and functionality.
  • You can verify the static IP setup using the ip address show command to confirm the changes.

Implementing these steps will help you maintain an efficient and reliable networking environment.

How to configure static IP on Linux terminal?

Everything. So on the next line we'll add a space and we'll use the command. Address to give it an address in my case 192. 1681.194 which is its current network. Address then net mask 255255255.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

📚 Related Tutorials

How to Setup WordPress Nginx Cloudflare Ubuntu Fast
CMS How to Setup WordPress Nginx Cloudflare Ubuntu Fast
How to Install NetData on Ubuntu 24.04
Ubuntu Linux How to Install NetData on Ubuntu 24.04
How to Install Emby Media Server on Ubuntu 24.04
Ubuntu Linux How to Install Emby Media Server on Ubuntu 24.04
How to Install RubyMine on Ubuntu 24.04
Ubuntu Linux How to Install RubyMine on Ubuntu 24.04

No comments yet — be the first to share your thoughts!

Leave a Comment

Your email address will not be published. Required fields are marked *