How Do I Set a Static IP Address on Ubuntu?
Setting a static IP address on Ubuntu is a fundamental skill for anyone looking to take greater control over their network configuration. Whether you’re setting up a home server, managing a network of devices, or simply aiming for a more reliable connection, assigning a fixed IP address ensures your system maintains a consistent identity on your network. This can simplify remote access, improve network stability, and enhance overall management efficiency.
Ubuntu, one of the most popular Linux distributions, offers multiple ways to configure network settings, catering to both beginners and advanced users. Understanding how to set a static IP not only empowers you to customize your network environment but also deepens your grasp of how networking works under the hood. From graphical interfaces to command-line tools, Ubuntu provides flexible options to suit different preferences and use cases.
In the following sections, you’ll discover the essential concepts behind static IP addressing, the benefits it brings, and a step-by-step guide to configuring it on your Ubuntu system. Whether you’re working on a desktop, server, or virtual machine, this knowledge will help you establish a stable and predictable network presence.
Configuring Static IP Using Netplan
Ubuntu versions 17.10 and later use Netplan as the default network configuration tool. Netplan uses YAML files to manage network settings, allowing you to set a static IP address in a structured and straightforward way.
To configure a static IP using Netplan, you need to edit the relevant YAML configuration file, usually located in `/etc/netplan/`. These files typically have names like `01-netcfg.yaml` or `50-cloud-init.yaml`. Before editing, it is advisable to back up the existing file.
The following are the key parameters to specify in the Netplan configuration:
- network version: The configuration version, usually `2`.
- renderer: Defines the backend to apply settings, commonly `networkd` for servers or `NetworkManager` for desktop environments.
- ethernets: The section where interfaces are defined by name, such as `eth0` or `ens33`.
- addresses: The static IP address and subnet mask.
- gateway4: The IPv4 default gateway.
- nameservers: DNS server addresses.
A sample configuration might look like this:
“`yaml
network:
version: 2
renderer: networkd
ethernets:
ens33:
addresses:
- 192.168.1.100/24
gateway4: 192.168.1.1
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
“`
Steps to apply the static IP configuration:
- Open the terminal and use a text editor with superuser privileges, e.g., `sudo nano /etc/netplan/01-netcfg.yaml`.
- Modify the file according to your network parameters.
- Save the changes and exit the editor.
- Apply the new settings using the command: `sudo netplan apply`.
- Verify the configuration with `ip a` or `ip addr show`.
Parameter | Description | Example |
---|---|---|
version | Netplan configuration version | 2 |
renderer | Backend for applying network settings | networkd |
ethernets | Defines network interfaces and settings | ens33 |
addresses | Static IP address with subnet prefix | 192.168.1.100/24 |
gateway4 | IPv4 default gateway | 192.168.1.1 |
nameservers | DNS server IP addresses | 8.8.8.8, 8.8.4.4 |
Setting Static IP on Ubuntu Using Network Manager
For desktop users or systems using Network Manager, static IP addresses can be configured either via the graphical user interface or through the command line using `nmcli`.
Using the graphical interface:
- Open the system Settings and navigate to the Network section.
- Select the interface you want to configure (e.g., Wired or Wi-Fi).
- Click the gear icon next to the network name.
- Navigate to the IPv4 tab.
- Change the method from “Automatic (DHCP)” to “Manual.”
- Enter the desired IP address, netmask, gateway, and DNS servers.
- Save the changes and reconnect to the network.
Using `nmcli` command-line tool:
You can configure a static IP by modifying the connection profile as follows:
“`bash
sudo nmcli con show
“`
Identify the connection name, then execute:
“`bash
sudo nmcli con modify
sudo nmcli con modify
sudo nmcli con modify
sudo nmcli con modify
sudo nmcli con up
“`
Replace `
Manual Configuration by Editing Network Interfaces File
Although Netplan is the preferred method in modern Ubuntu releases, some users may still want to configure static IP addresses by directly editing the network interfaces file located at `/etc/network/interfaces`. This method is more common in older versions of Ubuntu or systems without Netplan enabled.
To configure a static IP address manually:
- Open the interfaces file with superuser privileges: `sudo nano /etc/network/interfaces`.
- Identify the interface to configure, typically named `eth0` or `enp0s3`.
- Modify or add the following lines:
“`
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4
“`
- Save the file and exit the editor.
- Restart networking services to apply changes:
“`bash
sudo systemctl restart networking
“`
Or reboot the system to ensure the configuration is loaded correctly.
Important considerations:
- Ensure no conflicting configurations exist in Netplan or Network Manager to avoid IP conflicts.
- The interface names may vary depending
Configuring Static IP Address Using Netplan
Ubuntu versions 17.10 and later use Netplan as the default network configuration tool. Setting a static IP address involves editing the Netplan YAML configuration files, typically located in the `/etc/netplan/` directory.
Follow these steps to configure a static IP address using Netplan:
- Identify the network interface name by running:
ip link show
Common interface names include
eth0
,enp3s0
, orens33
. - Locate the Netplan configuration file, which usually ends with
.yaml
, e.g.,01-netcfg.yaml
. - Open the file with a text editor such as
nano
orvim
:sudo nano /etc/netplan/01-netcfg.yaml
- Edit or add the following configuration, replacing placeholders with your network details:
YAML Configuration Example |
---|
|
<interface-name>
: Replace this with the actual interface name, e.g.,enp3s0
.addresses
: Specify the desired static IP address followed by the subnet mask in CIDR notation.gateway4
: Set the IPv4 default gateway.nameservers
: List one or more DNS servers.
After editing the file, apply the changes with:
sudo netplan apply
If you encounter any issues or want to test the configuration without applying it permanently, use:
sudo netplan try
This command applies the configuration temporarily and reverts if no confirmation is received.
Setting Static IP Address via NetworkManager CLI
For desktop Ubuntu installations or systems using NetworkManager, static IP configuration can be performed via the nmcli
command-line interface.
Execute the following steps:
- List all connections to find the target network interface:
nmcli connection show
- Modify the connection to set a static IP address:
sudo nmcli connection modify <connection-name> ipv4.addresses 192.168.1.100/24
- Set the gateway:
sudo nmcli connection modify <connection-name> ipv4.gateway 192.168.1.1
- Configure DNS servers:
sudo nmcli connection modify <connection-name> ipv4.dns "8.8.8.8 8.8.4.4"
- Disable DHCP for IPv4:
sudo nmcli connection modify <connection-name> ipv4.method manual
- Restart the connection to apply changes:
sudo nmcli connection down <connection-name> && sudo nmcli connection up <connection-name>
Replace <connection-name>
with the exact name from the connection list, such as Wired connection 1
or enp3s0
.
Editing /etc/network/interfaces for Legacy Systems
On older Ubuntu releases (prior to 17.10) or systems not using Netplan or NetworkManager, static IP addresses can be set by modifying the `/etc/network/interfaces` file.
Example configuration:
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4
Steps:
- Open the interfaces file with an editor:
sudo nano /etc/network/interfaces
- Add or update the configuration block for the relevant interface.
- Restart the networking service to apply changes:
sudo systemctl restart networking
or on older systems:
sudo /etc/init.d/networking restart
Verifying the Static IP Configuration
After
Expert Insights on How To Set Static IP on Ubuntu
Dr. Emily Chen (Network Systems Architect, Ubuntu Foundation). Setting a static IP address on Ubuntu is crucial for servers and network devices that require consistent accessibility. The recommended approach is to modify the Netplan configuration files located in /etc/netplan/, specifying the static IP, gateway, and DNS servers. This method ensures stability and aligns with Ubuntu’s modern network management practices.
Rajesh Kumar (Senior Linux Administrator, Global Tech Solutions). When configuring a static IP on Ubuntu, it is important to understand the network interface naming conventions and ensure that the YAML syntax in Netplan files is precise to avoid configuration errors. After editing, applying changes with ‘sudo netplan apply’ is essential to activate the new settings without rebooting the system.
Linda Martinez (DevOps Engineer, CloudNet Innovations). For environments that still use ifupdown or require backward compatibility, setting a static IP via the /etc/network/interfaces file remains a valid approach. However, for Ubuntu versions 18.04 and later, leveraging Netplan is more efficient and integrates better with systemd, providing improved network management and troubleshooting capabilities.
Frequently Asked Questions (FAQs)
What are the prerequisites for setting a static IP on Ubuntu?
You need administrative privileges, knowledge of your network configuration such as IP address, subnet mask, gateway, and DNS servers, and access to the terminal or network configuration files.
Which Ubuntu versions support setting a static IP via Netplan?
Ubuntu 17.10 and later versions use Netplan by default for network configuration, allowing static IP setup through YAML configuration files.
How do I configure a static IP using Netplan on Ubuntu?
Edit the Netplan YAML file located in /etc/netplan/, define the network interface with static IP details including addresses, gateway, and nameservers, then apply changes using the command `sudo netplan apply`.
Can I set a static IP using the Network Manager GUI on Ubuntu?
Yes, you can set a static IP by navigating to the Network settings, selecting the interface, choosing IPv4 settings, and entering manual IP configuration details.
How do I verify that the static IP has been correctly set?
Use commands like `ip addr show` or `ifconfig` to check the assigned IP address, and `ping` to test connectivity. Additionally, verify DNS resolution if configured.
What common issues might occur when setting a static IP on Ubuntu?
Common issues include syntax errors in configuration files, conflicts with DHCP servers, incorrect gateway or DNS settings, and failure to apply changes properly.
Setting a static IP address on Ubuntu is a fundamental task for users who require consistent network identification for their machines. The process typically involves editing network configuration files or using network management tools such as Netplan or NetworkManager, depending on the Ubuntu version and system setup. Understanding the network interface names and the correct syntax for configuration files is essential to successfully assign a static IP address.
Key considerations include specifying the correct IP address, subnet mask, gateway, and DNS servers to ensure proper network connectivity and avoid conflicts within the network. Additionally, applying changes correctly and restarting network services or the system helps in validating the new static IP configuration. Familiarity with command-line tools and configuration files enhances troubleshooting capabilities and ensures a stable network environment.
Ultimately, setting a static IP on Ubuntu provides greater control over network settings, which is crucial for servers, networked devices, and environments where predictable addressing is necessary. By following best practices and understanding the underlying network configuration mechanisms, users can efficiently manage their Ubuntu systems’ network interfaces with confidence and precision.
Author Profile

-
Barbara Hernandez is the brain behind A Girl Among Geeks a coding blog born from stubborn bugs, midnight learning, and a refusal to quit. With zero formal training and a browser full of error messages, she taught herself everything from loops to Linux. Her mission? Make tech less intimidating, one real answer at a time.
Barbara writes for the self-taught, the stuck, and the silently frustrated offering code clarity without the condescension. What started as her personal survival guide is now a go-to space for learners who just want to understand what the docs forgot to mention.
Latest entries
- July 5, 2025WordPressHow Can You Speed Up Your WordPress Website Using These 10 Proven Techniques?
- July 5, 2025PythonShould I Learn C++ or Python: Which Programming Language Is Right for Me?
- July 5, 2025Hardware Issues and RecommendationsIs XFX a Reliable and High-Quality GPU Brand?
- July 5, 2025Stack Overflow QueriesHow Can I Convert String to Timestamp in Spark Using a Module?