How to Set Static IP Ubuntu [2 Easy Methods]

Written by

Reviewed by

Last updated: June 6, 2024

Expert verified

SVG Image


To set static IP Ubuntu, you can follow these steps:

  1. View your current IP address using ifconfig and check its details like subnet mask and gateway.
  2. List all network interfaces on Ubuntu with ip link show, showing their names and status.
  3. Check the status of the desired interface with ip a show [interface].
  4. Ensure the selected static IP falls within your network’s range but outside the DHCP pool to avoid conflicts.
  5. Edit the netplan configuration file, adding the desired static IP address, subnet mask, gateway, and DNS settings. Save the changes, restart the networking service, and verify the new static IP using ifconfig

Continue reading the guide below to learn the step-by-step methods to set static IP Ubuntu. Also, learn about the common errors that can occur during configuration and the best practices to follow.

Have you ever experienced the frustration of losing network connectivity because your IP address keeps changing? I know how annoying that can be. Configuring a static IP address on your Ubuntu system is the solution you need for a stable and reliable network connection. In this post, I’ll guide you through the process with detailed, step-by-step instructions for both GUI and command-line methods.

You’ll also find tips on troubleshooting common errors and best practices to ensure your setup is efficient and secure. By the end of this guide, you’ll have the knowledge to maintain a consistent IP address for your devices, improving your network stability and performance.

What is a Static IP Address?

An IP address is like a home address for your computer on a network. It helps other devices find and communicate with your computer. A static IP address is a fixed address that doesn’t change. Once you assign it to a device, it stays the same. This is useful for devices like servers, printers, or any equipment that needs a constant, unchanging address.

Dynamic vs. Static IP Addresses

How to Set Static IP Ubuntu?

To set a static IP on Ubuntu, first, open the terminal. Use ip addr show to find your network interface name. Edit the Netplan configuration file with sudo nano /etc/netplan/01-netcfg.yaml. Add your static IP details under the ethernets section. Save and apply changes with sudo netplan apply. Verify your new static IP with ip addr show again.

That was the quick answer. Keep reading to learn the detailed steps to use Netplan to set static IP and GUI method to set static IP Ubuntu:

1. Configure Static IP Using Netplan

Follow these steps to Ubuntu configure static IP address using Netplan:

  1. Open a Terminal.
opening terminal 39
  1. Run the following command to view your current IP address:
  1. This will show you the IP address, subnet mask, and gateway address of your current network interface.
viewing current ip address
  1. Use the following command to list all network interfaces on your Ubuntu system:
ip link show
  1. This will show you a list of all the network interfaces on your system, including their names and status.
listing available network interface
  1. Check the status of each interface with by running the following command to ensure they are up and running.
ip a show [interface]

Replace interface with the interface name of which you want to check the status of.

checking status of network interface
  1. Know your network’s subnet mask and gateway address for proper IP assignment. Select an IP address that falls within your network’s address range but outside the DHCP pool. Avoid using IP addresses that are already assigned to other devices.
  2. Run the following command to check for any conflicting responses.
ping [static IP address]
  1. If you receive responses, the IP address is already in use, and you should choose another.
checking for ip address conflicts
  1. Run this command to list netplan configuration file:
ls /etc/netplan/
  1. The command will list the netplan configuration file.
listing netplan configuration file
  1. Now run the following command:
sudo cp /etc/netplan/01-network-manager-all.yaml /etc/netplan/01-network-manager-all.yaml.bak
  1. The command will create a backup of netplan configuration.
creating backup of netplan configuration file


  1. Now execute the command:
sudo nano /etc/netplan/01-netcfg.yaml
  1. The command will open the netplan configuration file.
opening netplan configuration file
  1. Add the following lines below it, adjusting the values accordingly:
 version: 2
  renderer: NetworkManager
   enp0s3:  # Change this to your interface name if different
     dhcp4: no
      addresses: []  # Replace with your desired static IP and subnet mask (e.g., "")
      gateway4:  # Replace with your gateway address
        addresses: [,]  # Replace with your DNS server ad
  1. Applying Changes and Restarting the Network Service. Save the changes and exit the text editor (press Ctrl + X, then Y, and Enter).
applying changes to netplan configuration file


  1. Restart the networking service using the command:
sudo systemctl restart NetworkManager
  1. The command will restart the networking services.
restarting network service
  1. Run ifconfig in the Terminal to verify that the new static IP address is assigned to your network interface.
verifying configuration

2. Configuring Static IP Address via GUI

To configure Ubuntu static IP address using graphical user interface, follow these detailed steps:

Configuring a static IP address via the graphical user interface (GUI) on Ubuntu is ideal for users who prefer a visual approach over command-line operations. This method is user-friendly and straightforward, suitable for desktop environments where the network settings can be easily accessed and modified.

  1. Click on the system menu at the top-right corner of your screen.
opening system menu 1
  1. Select Settings from the dropdown menu to open the Settings application.
opening settings menu 1
  1. In the Settings application, find and click on Network in the left sidebar. Under the Network section, identify the network interface you want to configure (e.g., Wired or Wi-Fi).
navigating to network option and selecting network
  1. Click on the gear icon (⚙️) next to the network interface.
opening settings of network interface
  1. In the network settings window, navigate to the IPv4 tab.
navigating to IPv4 tab
  1. Change the Method from Automatic (DHCP) to Manual. Enter the static IP address, netmask, and gateway provided by your network administrator or obtained through network commands.
entering ip address netmask gateway
  1. Enter the DNS server addresses, separated by commas.
entering DNS server address
  1. Click the Apply button to save the configuration.
saving network configuration
  1. Restart the network interface or reboot your system to ensure the changes take effect. Open a terminal window and use the following command to verify that the static IP address has been assigned correctly.
ip addr show
verifying the changes 1
  1. Test your network connection by pinging a known address, such as:
testing network connection

Dynamic vs. Static IP Addresses

FeatureDynamic IP AddressStatic IP Address
AssignmentAutomatically assigned by the network (e.g., router)Manually assigned by the user or network administrator
IP Address ChangeChanges each time the device connectsRemains the same
Ease of SetupEasy, requires no manual configurationRequires manual setup and configuration
UsageIdeal for most home networks and temporary connectionsIdeal for servers, printers, and devices needing a constant address
Network ManagementSimple, no need to keep track of addressesRequires management to avoid conflicts
ReliabilityMay vary, as the IP can changeHigh, as the IP is consistent and reliable
ExampleSmartphones, laptops connecting to Wi-FiWeb servers, network printers, IP cameras

Best Practices for Static IP Configuration

Configuring a static IP address on your network can provide numerous benefits, such as enhanced stability, secure hosting, and improved network performance. To ensure a smooth and efficient setup, it’s crucial to follow best practices that guarantee a reliable and hassle-free static IP configuration. Here are four best practices to follow:

  • 🔒 Regularly Review and Update IP Settings: As networks evolve and devices change, it’s essential to review and update your static IP settings periodically. Over time, the initial IP allocations might become inadequate or conflicting, leading to potential connectivity issues. By regularly auditing your IP address assignments, you can ensure smooth communication and prevent any unnecessary disruptions.
  • 📝 Keep a Log of Network Changes: Maintaining a detailed log of all network changes, including static IP configurations, can be invaluable in troubleshooting and resolving issues. Should any problems arise in the future, the log will serve as a comprehensive reference, allowing you to revert to previously working settings or identify the source of the problem more efficiently.
  • 🔥 Implement Additional Security Measures: While static IPs offer stability, they can also be more susceptible to targeted attacks. To enhance network security, consider implementing additional measures such as firewalls, intrusion detection systems, and access control lists. These extra layers of protection will fortify your network, safeguard sensitive data, and minimize the risk of unauthorized access.
  • 🔄 Plan for Network Scalability: As your network grows, it’s vital to plan for scalability in your static IP configuration. Ensure that the selected IP address ranges are ample enough to accommodate future expansion without causing conflicts. Proactively consider the potential addition of new devices, services, or users to avoid potential headaches down the road.

Common Errors in Static IP Configuration

Configuring a static IP address on your Ubuntu system can greatly improve network stability and security. However, mistakes during the setup process can lead to connectivity issues and disruptions. Here, I’ll highlight some of the most common errors encountered during static IP configuration and how to avoid them.

  • 🚫 IP Address Conflict: One of the most common errors is assigning a static IP address that conflicts with an existing device on the network. This can cause communication problems and lead to intermittent connectivity. Always ensure you choose an IP address outside the DHCP pool and verify that it’s not already in use by another device.
  • ⚙️ Incorrect Network Settings: Incorrectly configuring network settings, such as the subnet mask or gateway address, can result in isolation from the network or the internet. It’s crucial to double-check and accurately enter the necessary details when setting up a static IP address. Verify the subnet mask and gateway information with your network administrator or router settings.
  • 🔌 Interface Down or Inactive: Another common error is forgetting to activate the network interface after making changes. If the interface remains down or inactive, your static IP configuration won’t take effect. Always restart the networking service or enable the interface using the appropriate commands to ensure your changes are applied correctly.
  • 📄 Typos in Configuration Files: Typos or syntax errors in configuration files, such as /etc/network/interfaces, can lead to unexpected behavior and prevent the static IP address from being applied. Carefully review the files for any errors and use a text editor that highlights syntax to avoid mistakes. Additionally, creating a backup of the original files before modification can be beneficial in case of any mishaps.

Ubuntu Set Static IP: In a Nutshell

By configuring a static IP address on Ubuntu, you ensure a stable and reliable network setup. Remember to avoid common errors like IP conflicts and incorrect network settings for a smooth configuration process.

For further learning, I recommend exploring:

  • How to fix the “ifconfig: command not found” error, which will help you troubleshoot essential network commands.
  • Understanding how to restart network interfaces in Linux can enhance your ability to manage network settings effectively.
  • Additionally, learning how to change IP addresses in Linux will give you greater flexibility and control over your network configuration.

Frequently Asked Questions

Can I configure multiple static IP addresses on one Ubuntu system?

Yes, Ubuntu allows you to configure multiple static IP addresses on a single network interface through a feature called IP aliasing. By assigning additional IP addresses to the same interface, you can have multiple distinct network identities. To achieve this, edit the network configuration file, typically located at /etc/network/interfaces. Add additional configurations for each desired IP address, using the :X notation (e.g., eth0:1, eth0:2) to differentiate them. Save the changes and restart the networking service with sudo service networking restart to apply the configurations. Each alias will act as an independent static IP address on your Ubuntu system.

How do I reset my network settings to default if there’s an issue?

If you encounter network issues after configuring static IPs, fear not, as you can revert to the default network settings using the backup you wisely created. Locate the backup of your original network configuration files and restore them to their respective locations. Alternatively, open the configuration files and manually change the static IP settings back to DHCP mode. After saving the changes, restart the networking service with sudo service networking restart to activate the default network settings and resolve any issues you were facing.

Can I use a static IP address with both wired and wireless connections?

Absolutely! Ubuntu allows you to configure static IP addresses for both wired and wireless interfaces independently. You can assign a static IP address to your wired connection, typically eth0, and another static IP to your wireless connection, commonly wlan0. This flexibility comes in handy, especially when you have different network requirements for your wired and wireless connections. To configure static IPs for each interface, use either the command-line method or the Network Manager GUI, making sure to select the correct interface and enter the relevant static IP information for each connection.

Is it possible to switch back to a dynamic IP address after configuring a static IP?

Yes, you can easily switch back to a dynamic IP address after configuring a static IP on your Ubuntu system. To revert to DHCP mode, access the network configuration files (usually located at /etc/network/interfaces) and change the configurations from static to dhcp. Simply remove the lines specifying the static IP address, subnet mask, and gateway details. Save the changes and restart the networking service with sudo service networking restart. Your Ubuntu system will now acquire its IP address dynamically through DHCP, restoring its ability to receive IP assignments from the network router.



Ojash is a skilled Linux expert and tech writer with over a decade of experience. He has extensive knowledge of Linux's file system, command-line interface, and software installations. Ojash is also an expert in shell scripting and automation, with experience in Bash, Python, and Perl. He has published numerous articles on Linux in various online publications, making him a valuable resource for both seasoned Linux users and beginners. Ojash is also an active member of the Linux community and participates in Linux forums.



Akshat is a software engineer, product designer and the co-founder of Scrutify. He's an experienced Linux professional and the senior editor of this blog. He is also an open-source contributor to many projects on Github and has written several technical guides on Linux. Apart from that, he’s also actively sharing his ideas and tutorials on Medium and Attirer. As the editor of this blog, Akshat brings his wealth of knowledge and experience to provide readers with valuable insights and advice on a wide range of Linux-related topics.

Share this article
Shareable URL
Prev Post

How to Install GLIBC on Ubuntu [22 Simple Steps]

Next Post

How to Verify Checksum Linux [4 Proven Methods]

Leave a Reply

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

Read next