How to Set Up a Static IP on Ubuntu 24.04
Setting up a static IP on Ubuntu 24.04 involves telling the computer to always use the same network address. This fixed address, unlike a temporary one given out by your router, makes it easier for other devices to find your computer reliably.
A static IP is like having a permanent street address for your computer on the network. This is super helpful for things like running a home server or ensuring a network printer is always found in the same spot.
Ubuntu 24.04 uses a tool called Netplan to manage network settings. You’ll work with simple configuration files to tell your system which static IP address to use permanently.
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.
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.
sudo nano /etc/netplan/01-netcfg.yaml
Then, enter the following network configuration details to use a static IP address for your device.
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.
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.
ip address show
The command should output something similar to the one below.
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 showcommand 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?
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.
No comments yet — be the first to share your thoughts!