- Buying Guides

Complete Guides by How-To Geek
Our latest product roundups, reader favorites, more from how-to geek, latest geek news, latest reviews, across lifesavvy media.
Join 425,000 subscribers and get a daily digest of news, geek trivia, and our feature articles.
By submitting your email, you agree to the Terms of Use and Privacy Policy .
How to Set a Static IP Address in Ubuntu
Dave McKay first used computers when punched paper tape was in vogue, and he has been programming ever since. After over 30 years in the IT industry, he is now a full-time technology journalist. During his career, he has worked as a freelance programmer, manager of an international software development team, an IT services project manager, and, most recently, as a Data Protection Officer. His writing has been published by howtogeek.com, cloudsavvyit.com, itenterpriser.com, and opensource.com. Dave is a Linux evangelist and open source advocate. Read more...
Lowell is the founder and CEO of How-To Geek. He’s been running the show since creating the site back in 2006. Over the last decade, Lowell has personally written more than 1000 articles which have been viewed by over 250 million people. Prior to starting How-To Geek, Lowell spent 15 years working in IT doing consulting, cybersecurity, database management, and programming work. Read more...

Your home network relies on IP addresses to route data between devices, and sometimes on reconnecting to the network a device’s address can change. Here’s how to give an Ubuntu Linux computer a permanent IP address that survives reboots.
Dynamic and Static IP Addresses Setting a Static IP Address in Ubuntu Using the GNOME Desktop and Applications Connection Convenience
Dynamic and Static IP Addresses
Everything on your network home network, whether it’s using a wired connection or Wi-Fi, has an IP address . IP stands for Internet Protocol. An IP address is a sequence of four numbers separated by three dots. Each IP address that is unique within that network.
IP addresses act as numeric labels. Your router uses these labels to send data between the correct devices. Usually, your router assigns IP addresses. It knows which IP addresses are in use and which are free. When a new device connects to the network, it requests an IP address and the router allocates one of the unused IP addresses. This is called DHCP, or dynamic host configuration protocol .
When a device is restarted or powered off and on, it may receive its old IP address once more, or it might be allocated a new IP address. This is normal for DHCP and it doesn’t affect the normal running of your network. But if you have a server or some other computer that you need to be able to reach by its IP address, you’ll run into problems if its IP address doesn’t survive power downs or reboots.
Pinning a specific IP address to a computer is called allocating a static IP address . A static IP address, as its name suggests, isn’t dynamic and it doesn’t change even if the computer is power-cycled .
Setting a Static IP Address in Ubuntu
We’re demonstrating this technique on Ubuntu, but it ought to work on any Linux distribution. The nmcli network manager tool was released in 2004, so it should be present on just about any standard distribution.
Let’s take a look at the network connections that already exist on the computer. We’re using the connection command with the show argument.
This displays some information about each connection. We only have a single connection configured.
The output is wider than the terminal window. This is the information that we’re shown.
- Name : Our network connection is called “netplan-enp0s3.”
- UUID : The universally unique identifier Linux uses to reference this connection internally.
- Type : This is an ethernet connection.
- Device : This connection is using the “enp0s3” network interface. It’s the only network card in this computer.
We can use the ip command to discover the IP address this computer is using.
In the output we can see the “enp0s3” entry, and its current IP address, 192.168.86.117. The “/24” is a shorthand way of saying that this network uses a 255.255.255.0 subnet mask . Take a note of this number, we’ll need to use it later.
We need to choose the IP address we’re going to set as our static IP address. Obviously, you can’t use an IP address that is already in use by another device. One safe way to proceed is to use your current IP address. We know for certain that nothing else is using that IP address.
If we want to use a different IP address, try pinging it. We’re going to test whether IP address 192.168.86.128 is in use. If everything else on your network uses DHCP and you get no response to the ping command, it should be safe to use.
Even if another device had previously used that IP address, it’ll be given a new IP address when it next boots up. Nothing is responding to the ping requests. We’re clear to go ahead and configure 192.168.86.128 as our new static IP.
We also need to know the IP address of your default gateway , which will usually be your broadband router. We can find this using the ip command and the route option, which we can abbreviate to “r.”
The entry that starts with “default” is the route to the default gateway. Its IP address is 192.168.86.1. Now we can start to issue commands to set up our static IP address.
The first command is a long one.
Taken in small chunks, It’s not as bad as it looks. We’re using sudo . The nmcli arguments are:
- con : Short for “connection.”
- add : We’re going to add a connection.
- con-name “static-ip” : The name of our new connection will be “static-ip.”
- ifname enp0s3 : The connection will use network interface “enp0s3.”
- type ethernet : We’re creating an ethernet connection.
- ip4 192.168.86.128/24 : The IP address and subnet mask in classless inter-domain routing notation . This is where you need to use the number you took a note of earlier.
- gw4 192.168.86.1 : The IP address of the gateway we want this connection to use.
To make our connection a functioning connection, we need to provide a few more details. Our connection exists now, so we’re not adding anything, we’re modifying settings, so we use the mod argument. The setting we’re changing is the IPv4 DNS settings. 8.8.8.8 is the IP address of Google’s primary public DNS server , and 8.8.4.4 is Google’s fallback DNS server.
Note that there is a “v” in “ipv4.” In the previous command the syntax was “ip4” without a “v.” The “v” needs to be used when you’re modifying settings, but not when adding connections.
To make our IP address static, we need to change the method which the IP address obtains its value. The default is “auto” which is the setting for DHCP. We need to set it to “manual.”
And now we can start or “bring up” our new connection.
We didn’t get any error messages which is great. Lets use nmcli to look at our connections once more.
Here’s the output:
Our static-ip connection is active and using device “enp0s3.” The existing connection “netplan-enp0s3” is no longer associated with a physical network interface because we’ve pinched “enp0s3” from it.
Using the GNOME Desktop and Applications
Click the icons at the far-right end of the system bar to show the system menu, then click on the “Wired Connected” menu option. If you’re using a wireless connection, instead click the name of your Wi-Fi network.
The available connections are displayed. A dot indicates which is in use. Our new connection is the active connection. Click the “Wired Settings” or “Wi-Fi Settings” menu option.
The details of the active connection are displayed. We can see our new “static-ip” connection has the IP address, default gateway, and DNS servers that we set for it. You can swap between the available connections by clicking directly on their names.
Click the cog icon to enter the settings for the “static-ip” connection.
A dialog box opens. Click on the “IPv4” tab.
Because we set our new IP address to be static, the “Manual” radio button is selected. You could change this back to DHCP by selecting the “Automatic (DHCP)” radio button, and clicking the green “Apply” button.
To create a new connection using the “Settings” application, click the “ + ” icon on the “Networks” page, above the list of wired connections.
A dialog appears. We need to provide a name for this connection.
We’re calling our new connection “static-2.” Click the “IPv4” tab.
Select the “Manual” radio button, and complete the “Address”, “Netmask”, and “Gateway” fields. Also complete the DNS field, and then click the green “Apply” button. Note the comma between the DNS entries.
Our new connection is listed in the “Wired” connections pane.
RELATED: How to Assign a Static IP Address in Windows 10 or 11
Connection Convenience
Using the nmcli command or the GNOME desktop and apps, you can hop between network connections very easily and very quickly.
It’s more convenient to have a selection of connection profiles and move between them as you need to, rather than to have one that you keep editing. If something goes horribly wrong with the connection you’re editing or adding, you can always fall back on one of the existing connections.
RELATED: How to Use bmon to Monitor Network Bandwidth on Linux
- › How to Find Your IP Address on Windows 11
- › How to Find Your IP Address on a Windows 10 PC
- › How to Change Your IP Address
- › How to Assign a Static IP Address in Windows 10 or 11
- › How to Get Your Public IP in a Linux Bash Script
- › The Best VPN Services for Gaming in 2023
- › Controller vs. Mouse and Keyboard: Which Is Better?
- › Amazon Won’t Let You Buy Kindle or Print Magazines Anymore
Log in or Sign up
Linux basics - set a static ip on ubuntu, on this page, network configuration on ubuntu 22.04, ubuntu 20.04, and ubuntu 18.04, configure a static ip address with netplan on ubuntu, configure a dhcp address with netplan, more netplan config options, network configuration on ubuntu 12.04 - 17.04 (incl. ubuntu 16.04 lts), step 1: configure the network interface, step 2: configure the dns servers, step 3: restart networking, configure the hostname, suggested articles, 36 comment(s).
Or does it make more sense to actually split things up like you did within the resolv.conf and interfaces configuration folder?
Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
How do I set a static IP in Ubuntu?
I am a new with Linux, having years experience with Windows servers/desktops and am having issues setting a static IP. I am using a method used for previous versions of Ubuntu, which doesn't seem to work with 16.04
I have used the command sudo nano /etc/network/interface and added the following
I have rebooted the system and the Ethernet is pretty much dead, ping doesn't work at all. I have tried to modify /etc/NetworkManager/NetworkManager.conf and made the following changes
With this I can get Ethernet to work sporadically, however it eventually fails.
I have tried this configuration on two other machines plus a virtual machine as well and all have the same results. I can confirm these settings work fine when I install Windows on any of these machines. As well when I let DHCP auto configure, everything works fine no issues.
I figure I am missing something here, setting up a static IP should not be difficult at all.
- network-manager

- the only thing I notice and it may have just been a typo here but I would change the Dns-nameservers to dns-nameservers probably not going to do anything to solve this issue but may stop other issues from happening – John Orion May 2, 2016 at 0:20
- 1 Dns-nameservers is acceptable syntax wise so it shouldn't be an issue. When it was working with DHCP, did you run an ifconfig to check the interface name or did you assume it was enp0s25? Also do you have an auto enp0s25 at the top of your config file? If you don't its possible that the interface is just not coming up on boot. – Andrew May 2, 2016 at 0:30
- Please edit your question and post the exact content of your /etc/network/interfaces file. While editing your message, highlight the text of this file, then click on the {} code link on the top of the message editor so that it will properly format the text making it easier for us to read the content. Also do execute this command ip address and perform the same steps to {} (code format) that output. – L. D. James May 2, 2016 at 4:05
9 Answers 9
I had the same problem and this was my solution:
and paste (altering for your network) this under # The primary network interface :
You can get correct interface name using Terminal command ifconfig -a on ubuntu 16.04 or ip address on 18.04+
Shutdown your Virtual Machine and then!!! Go to network settings and click on refresh MAC address button a few times :)

and start your VM and you should get internet!
UPDATE 20.02.2019
For ubuntu 18.04+ you need to edit this file
- 2 Great thanks I appreciate it. It seems to work now, with no problems. It is very solid right now! – TeeStar May 7, 2016 at 2:07
- In addition to the dns-nameservers fix, I had to use this fix: askubuntu.com/questions/574569/… My ISP is monkeybrains.net. – BSalita Aug 22, 2016 at 23:38
- does not work in my VMWare player with ubuntu16.04 – ZhaoGang Mar 8, 2021 at 6:26
- I suppose you didn't configure the network properly in VM-Ware Player.... but your bigger problem is: Why do you still use Ubuntu 16.04... The support is "end of life"... – lewis4u Mar 8, 2021 at 7:33
Setting the static IP address as above in the accepted answer here works, but one has to flush the old IP addr setting and then restart networking.service:
Then verify it is correct:
- 2 The flush was necessary to avoid the old address being present on the interface (based on ip addr ). The systemctl restart works too, though ifdown and ifup on the interface will work more selectively. – RichVel Nov 28, 2016 at 13:28
- 2 thx @Grant. adding flush made this work – Paweł Madej Feb 1, 2017 at 13:19
- 3 In Ubuntu 16.04 and newer flush is necessary! – Diego Duarte May 2, 2017 at 12:05

- 1 ifcace should be iface on line 5 – twoleggedhorse Jun 28, 2017 at 14:33
- @twoleggedhorse: Fixed the typo for the answer but I had to add a few # in the first line because you cannot have an edit without at least 6 changed characters that are not whitespace – Andrei Rînea Nov 28, 2017 at 17:11
sudo vim /etc/network/interfaces
sudo ifdown eth0 && sudo ifup eth0
- 10 Hi @lanni654321, maybe you should edit your answer and add a few word, briefly explaining what you are doing and why? i think that would make your answer even more helpful, what do you think? – Tshilidzi Mudau Oct 14, 2016 at 6:58
I had the same problem and the solution "was" simply... for me, at least.
And, create an empty file with the name of the network interface in:
It works...
I had the same problem and this was my solution: Remove all empty lines at the end of the file /etc/network/interface .

If your server is showing that old IP as well as new assigned IP, simply restart your server. It will automatically flush old IP and persist the new one. And if you don't want to restart your server, use this command:
sudo ip addr flush <your-interface-here>
Run this simple commands to see if your network interface(s) are set to come up when the machine boots / restarts.
If no lines are printed to standard output, then open /etc/network/interfaces with a text editor (vi, nano, sed) and hopefully you will see something similar to the image below below.

Obviously, if grep did not return any lines to the terminal window, the format of your /etc/network/interfaces cannot be very similar at all. :-) However, follow the format of the auto lines.
====================
Now, on your machine .
Don't know which interface names are available? Run this command.
The following command will return just the names of the network interfaces.

I used to set static IPs on my Ubuntu machines and then I noticed that I can just assign the IP address using my router. This may be the simplest solution. Just log in to your router, find the attached devices, and assign the IP address there.
Your Answer
Sign up or log in, post as a guest.
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service , privacy policy and cookie policy
Not the answer you're looking for? Browse other questions tagged networking network-manager dns dhcp ip or ask your own question .
- The Overflow Blog
- How to position yourself to land the job you want
- Building an API is half the battle: Q&A with Marco Palladino from Kong
- Featured on Meta
- We've added a "Necessary cookies only" option to the cookie consent popup
- The Stack Exchange reputation system: What's working? What's not?
- Announcement: AI-generated content is now permanently banned on Ask Ubuntu
Hot Network Questions
- Displaying Hasse diagram (directed edges in graph pointing upwards)
- What's the name of this binding type where the pages of a book are bound at different locations?
- hexagonal ball with internal structure
- How was altitude calculated before the invention of the altimeter?
- How tight does the top part of a presta need to be torqued?
- Was Freemasonry such a big problem in 1980s UK policing?
- What does "investing in credit" mean?
- Can the positive root of this polynomial be expressed elementarily?
- I arrive 30 minutes before my visa start date. Would I be allowed to board the plane in my home airport?
- Why does Windows 11 PowerShell or terminal lack Linux command line tools?
- On top of itself
- Firefox very distorted, unusable
- Is there a specific field which addresses how to develop new software specifically for natural sciences?
- Preserve layout while using figures in columns in overlay
- How were rackmount workstations wired-up to mice, keyboards, monitors, etc?
- Does the Federal Reserve insure the money of all depositors?
- When should you reveal the motivations of a villain?
- Where is the extra hour? Eurostar London to Paris is 2hr 30m but departure is 3hrs 30m before arrival
- How close do gravitational 2-body hierarchy levels get?
- What is the concept of hole in semiconductor physics?
- What is the function of the pipe referred to as "Venting Pipe" in the picture and how is it different from the exhaust pipe?
- How to notate 3 quarters framed by eighths?
- If electric field inside a conductor is always zero, then why do free electrons move?
- Who first suggested weak stationarity and strict stationarity?
Your privacy
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy .

How to Assign Static IP Address on Ubuntu Linux
Brief: In this tutorial, you’ll learn how to assign static IP address on Ubuntu and other Linux distributions. Both command line and GUI methods have been discussed.
IP addresses on Linux Systems in most cases are assigned by Dynamic Host Configuration Protocol (DHCP) servers. IP addresses assigned this way are dynamic which means that the IP address might change when you restart your Ubuntu system . It’s not necessary but it may happen.
Dynamic IP is not an issue for normal desktop Linux users in most cases . It could become an issue if you have employed some special kind of networking between your computers.
For example, you can share your keyboard and mouse between Ubuntu and Raspberry Pi . The configuration uses IP addresses of both system. If the IP address changes dynamically, then your setup won’t work.
Another use case is with servers or remotely administered desktops. It is easier to set static addresses on those systems for connection stability and consistency between the users and applications.
In this tutorial, I’ll show you how to set up static IP address on Ubuntu based Linux distributions. Let me show you the command line way first and then I’ll show the graphical way of doing it on desktop.
Method 1: Assign static IP in Ubuntu using command line

Note for desktop users : Use static IP only when you need it. Automatic IP saves you a lot of headache in handling network configuration.
Step 1: Get the name of network interface and the default gateway
The first thing you need to know is the name of the network interface for which you have to set up the static IP.
You can either use ip command or the network manager CLI like this:
In my case, it shows my Ethernet (wired) network is called enp0s25:
Next, you should note the default gateway IP using the Linux command ip route :
As you can guess, the default gateway is 192.168.31.1 for me.
Step 2: Locate Netplan configuration
Ubuntu 18.04 LTS and later versions use Netplan for managing the network configuration. Netplan configuration are driven by .yaml files located in /etc/netplan directory.
By default, you should see a .yaml file named something like 01-network-manager-all.yaml, 50-cloud-init.yaml, 01-netcfg.yaml.
Whatever maybe the name, its content should look like this:
You need to edit this file for using static IP.
Step 3: Edit Netplan configuration for assigning static IP
Just for the sake of it, make a backup of your yaml file.
Please make sure to use the correct yaml file name in the commands from here onward.
Use nano editor with sudo to open the yaml file like this:
Please note that yaml files use spaces for indentation . If you use tab or incorrect indention, your changes won’t be saved.
You should edit the file and make it look like this by providing the actual details of your IP address, gateway, interface name etc.
In the above file, I have set the static IP to 192.168.31.16.
Save the file and apply the changes with this command:
You can verify it by displaying your ip address in the terminal with ‘ip a’ command.
If you don’t want to use the static IP address anymore, you can revert easily.
If you have backed up the original yaml file, you can delete the new one and use the backup one.
Otherwise, you can change the yaml file again and make it look like this:
Method 2: Switch to static IP address in Ubuntu graphically
If you are on desktop, using the graphical method is easier and faster.
Go to the settings and look for network settings. Click the gear symbol adjacent to your network connection.

Next, you should go to the IPv4 tab. Under the IPv4 Method section, click on Manual.
In the Addresses section, enter the IP static IP address you want, netmask is usually 24 and you already know your gateway IP with the ip route command.
You may also change the DNS server if you want. You can keep Routes section to Automatic.

Once everything is done, click on Apply button. See, how easy it is to set a static IP address graphically.
If you haven’t read my previous article on how to change MAC Address , you may want to read in conjunction with this one.
More networking related articles will be rolling out, let me know your thoughts at the comments below and stay connected to our social media.
Explained: Which Ubuntu Version Should I Use?
How to recover deleted files in linux [beginner's guide], reduce computer eye strain with this nifty tool in linux, how to run c/c++ programs in linux [terminal & eclipse], how to install windows 10 in virtualbox in linux, become a better linux user.
With the FOSS Weekly Newsletter, you learn useful Linux tips, discover applications, explore new distros and stay updated with the latest from Linux world

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to It's FOSS.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.
How to Configure Static IP Address on Ubuntu 22.04 LTS and 22.10
Switching from dynamic IP allocation to static IP addresses is easy on Ubuntu 22.04 "Jammy Jellyfish" and 22.10.
The IP address of most devices today is generated by the Dynamic Host Configuration Protocol (DHCP) server. A DHCP server assigns a dynamic IP address to your device when it's connected to a network. Thus, you have the chance to change this IP address from time to time.
On the other hand, a static IP refers to a fixed, immutable address, different from dynamic IPs. You can set static IP settings for Ubuntu versions 22.04 LTS and 22.10 in three different ways. Here's how to get started.
Set a Static IP on Ubuntu With the nmcli Command
It's pretty easy to configure Ubuntu 22.04 static IP settings using the nmcli command . nmcli is a text-based utility used to check the status of the wired connections you are using on your device.
With this command, you can access additional networking information such as your connection status, the name of your host device, and general permissions in your network configuration. Also, this command is very useful in your Ubuntu server static IP settings.
You can get information about your connection with the following command:
The output of this command will be as follows:
Create a static link with the command given below. Then, manually configure the enp0s3 and ipv4 settings with the appropriate parameters in the nmcli command:
If you use the nmcli connection show command again, you can see that the static link has been added.
After this process, add the static connection you created to the DNS IP:
Now use the command below to activate the connection:
If the output displays "connection successfully activated," you've successfully set up a static IP address on your machine.
You can consider using static IP addresses to avoid connection problems caused by dynamic IP addresses. A static IP address allows you to have a fixed identity and location when connected to the internet.
You can verify the static IP you want to assign to your device by running the following command:
Using Netplan for Static IP Settings on Ubuntu
Just like nmcli, another command you can use for setting a static IP on Ubuntu is netplan. You can easily make Ubuntu static IP settings using the netplan command in 22.04 LTS and 22.10 versions. To do this, follow the steps below.
First, find out the name of your network interface using the command below:
What you see here is your network interface name. This name may be different on each device.
Now, create a file named 01-netcfg.yaml in the /etc/netplan folder. Edit it with your favorite text editor.
Add the following lines to the file:
As you can see, you have disabled the DHCP IP setting with the dhcp4: no statement. You've then added the IP address and DNS settings assigned by Google.
After saving this file, run the following command to apply the changes:
Configure Static IP Settings on Ubuntu Graphically
The graphical network interface in Ubuntu 22.04 is quite useful if you don't want to use the command line. So much so that you can easily set the Ubuntu static IP address using this interface.
To do this, click on the Network icon in the upper right corner of your desktop. Then, select Wired Settings from the drop-down menu. Click on the Gear icon to open the settings window.
Then, switch to the IPv4 tab in the window that opens.
As you can see, DHCP is enabled by default. Change the IPv4 Method to Manual as you want to use a static IP instead of a dynamic one. Next, change your address, netmask, and gateway settings. Finally, modify your DNS setting and click the Apply button.
You must restart this wired connection for all these actions to take effect. To do this, simply toggle the switch next to the network name on and then off.
Why Should You Use Static IP Addresses?
You learned how to configure static IP settings in "Jammy Jellyfish" 22.04, the latest LTS version of Ubuntu, and 22.10, using both the graphical settings interface and the two terminal commands: nmcli and netplan. Also, now you know how to set a static IP on Ubuntu server 22.04.
Due to insufficient IP addresses, some service providers may assign the same address to two different users. In this case, connection problems can occur. Using static IP addresses instead does not cause such problems as it is user-specific, but beware as someone can misuse your IP address in several ways.
Daniel Miessler
How to Set a Static IP Address in Linux
Created/Updated: February 2, 2022

- Set Your Static IP in Ubuntu
- Set Your Static IP in CentOS
- Using the ip Command
ifconfig is being replaced by the ip command.
Configuring a static IP can be difficult in Linux because it’s different based on the distro and version you’re using. This guide will show you how to configure a static IP address on the most popular Linux distros.
As of version 17 of Ubuntu, networking is configured using Netplan , which is a YAML-based configuration system. It allows you to set your IP, netmask, gateway, and DNS all in one place.
Start by editing the file for your interface: in this case 01-netcfg.yaml .
vi /etc/netplan/ 01-netcfg.yaml
Editing your interface file
You’ll either see networkd or systemd in the renderer spot; keep that the same.
network: version: 2 renderer: networkd ethernets: enp0s3: dhcp4: no addresses: [192.168.2.2/24] gateway4: 192.168.1.1 nameservers: addresses: [8.8.8.8,8.8.4.4]
To have your changes take effect, restart networking with this command:
You can then apply this configuration by running netplan apply .
YAML configs are crazy about indentation, so if you get an error check there first.
netplan apply
Now let’s do the same thing in CentOS. Here we’ll need to edit things the old way using sysconfig and network-scripts:
vi /etc/sysconfig/network-scripts/ ifcfg-eth0
You’ll change what you see there to something like this:
HWADDR=$SOMETHING TYPE= Ethernet BOOTPROTO= none // turns off DHCP IPADDR= 192.168.2.2 // set your IP PREFIX=24 // subnet mask GATEWAY= 192.168.2.254 DNS1=1.1.1.2 // set your own DNS DNS2=1.0.0.2 DNS3=9.9.9.9 DEFROUTE=yes IPV4_FAILURE_FATAL=no NAME=eth0 DEVICE=eth0 ONBOOT= yes // starts on boot
You can then apply this configuration by running:
/etc/init.d/ network restart
Ok, that will get you up and running with a static IP on the two most common Linux distros. Now let’s take a deeper look at the new ip command.
Using ip and netplan
Most Linux nerds have been using ipconfig for a long time, but it’s now being replaced with a new command called ip . Here’s how to do some basic tasks using the new command.
Show your IP using ip
ip addr show
or even shorter and more efficient…
(both commands show all interfaces)
Show only one interface using ip
ip a show eth0

Bring an interface up or down using ip
ip link set eth1 up
ip link set eth1 down
Only show IPv4 interfaces
Ok, so now you should know how to set a static IP on both Ubuntu and CentOS, as well as how to get some basic network information using ip instead of ipconfig .
Happy hacking!

Written By Daniel Miessler
Recommended.
- Information Security
- Recommended Tutorials
- A Vim Primer
- A Tcpdump Primer
- Security Assessment Types
- URLs vs. URIs
- Unsupervised Learning
- Book Summaries

How to Set a Static IP Address On Ubuntu 22.04
The first task anyone would do after installing Ubuntu is setting an IP address to a system to connect to the network/internet. If the Wi-Fi router, ISP, or network doesn’t provide DHCP services, you must manually assign IP addresses.
Here, we will see how to set a static IP Address on Ubuntu 22.04, using,
- GNOME Control Center
- NetworkManager
You can use any method to set a static IP address on Ubuntu 22.04.
Find Network Interfaces on Ubuntu 22.04
You can run any of the below commands in a terminal to get a list of network interfaces available on the system.
The output of the ifconfig command on a desktop:
Here, we will see how to configure a static IP for enp0s3 (Wired) / wl01 (Wi-Fi).
IP Address : 192.168.0.10 Netmask : 255.255.255.0 Gateway : 192.168.0.1 DNS Server 1 : 192.168.0.1 DNS Server 2 : 8.8.8.8 Domain Name : itzgeek.local
Set Static IP Address on Ubuntu 22.04 Desktop
1. using gnome network manager.
Using the GNOME network control center to set a static IP address on In Ubuntu 22.04 desktop is straightforward.
Set IP for Wired Interface using GNOME
Open the Gnome control center using the gnome-control-center network command or go to Activities >> Settings >> Network .
Click on the gear icon on the Wired interface page and then IPv4 tab >> Manual >> Enter IP address, Netmask, Gateway, DNS (Toggle to disable Automatic DNS configuration) >> Apply .
Finally, use the toggle in the Network page to disable and enable the network interface to apply the IP address.
Set IP Address for Wi-Fi using GNOME
Click on your Wifi router name and then enter the router’s password to connect. Your laptop will automatically receive an IP address from a Wi-Fi router with a built-in DHCP service on a successful connection.
To assign a static IP address or Wi-Fi interface, click on the gear icon on the Wi-Fi interface page and then IPv4 tab >> Manual >> Enter IP address, Netmask, Gateway, DNS (Toggle to disable Automatic DNS configuration) >> Apply .
Finally, disable and enable the Wi-Fi interface to apply the IP address.
2. Using Netplan
Netplan is a utility for easily configuring networking on a Ubuntu system. It reads the configuration files .yaml present in the /etc/netplan directory.
3. Using NetworkManager CLI
Set ip for wired interface using nmcli.
First, let us list the available network connections.
Then, configure static IP address to wired interface.
Set IP Address for Wi-Fi using nmcli
First, list the available Wi-Fi access points using the below command.
Next, connect to the Wi-Fi access point.
Finally, run the below commands to apply the IP address
Set Static IP Address Using NetPlan on Ubuntu 22.04 Server
Netplan is a network configuration utility that reads YAML files and generates all network configurations for the renderer tool (NetworkManager or networkd) to configure the network on a system.
Netplan configuration files are found in the /etc/netplan/ directory.
Set IP for Wired Interface using Netplan
Now, create a new netplan configuration for the wired network interface.
Then, make changes to the below information and use it for your requirement.
Finally, apply all network configurations and restart renderers.
Set IP Address for Wi-Fi using Netplan
Wi-Fi Interface Name : wl01 Wireless Access Point Name : Raj Wireless Access Point Password : MyPass
First, create a new netplan configuration for the wired network interface.
And then generate the required configuration for the renderers.
Verify Static IP Address on Ubuntu 22.04
Verify the static IP address using the below commands.
Also, verify the DNS server’s entries.
That’s All.
How to Install Brave Browser on Fedora 36 / Fedora 35
How to Install phpMyAdmin with Nginx on Ubuntu 22.04
How to Install MySQL on Ubuntu 22.04
How to Install Cacti on Ubuntu 22.04
How to Install pgAdmin on Ubuntu 22.04 / Ubuntu 20.04
How to Set up DNS Server on Ubuntu 22.04 / Ubuntu 20.04
How to Install PostgreSQL on Ubuntu 22.04
How to Install Plex on Ubuntu 22.04

- CentOS 8 / RHEL 8
- CentOS 7 / RHEL 7
- CentOS 6 / RHEL 6
- LinuxMint 20
- Linux Mint 19
- Linux Mint 18
- Rocky Linux 8
- Ubuntu 22.04
- Ubuntu 20.04
- Ubuntu 18.04
- MySQL / MariaDB
- Other Tools
How to Configure Static IP Address on Ubuntu 20.04

A static or fixed IP address is an IP address that does not change. Whether you reboot your device or home router, your device with a static IP address will get the same IP address. The opposite of a static IP address is the dynamic IP address. A device that does not have a static IP address will get a dynamic IP address assigned by the DHCP (Dynamic Host Configuration Protocol) server, and it may change from time to time.

By default, a device connected to your home router whether it’s using cable or connected through WiFi will most likely get a dynamic IP address. And, if you use your managed Ubuntu VPS also as an FTP server of web server you would want to configure a static IP address for it, so you can reach the server using the same IP address. In this tutorial, we will show you how to configure a static IP address on Ubuntu 20.04.
Configure Static IP Address on Ubuntu Server 20.04
In Ubuntu server 20.04, the network configuration is managed by a utility called NetPlan. NetPlan is a new network configuration tool introduced in Ubuntu 17.10 to manage network settings. And during the Ubuntu 20.04 server installation, cloud-init will configure a dynamic IP address for the network interface on the server if the DHCP server is available.
First of all, we need to check what is the ethernet interface card that we want to configure the IP address for, we can run ip a or ip link command to see it. In this example, the interface that we are going to configure the static IP is ‘ens33’.

To proceed with configuring a static IP address on Ubuntu server 20.04, we have to make sure that cloud-init does not manage the network interface. To do it, let’s open cloud-init file at /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg and make sure that “network: {config: disabled}” entry is there. If the entry is missing, we have to create it.
Now, to configure a static IP address, we need to modify the YAML configuration file at /etc/netplan/00-installer-config.yaml. Please note, when editing a YAML file, make sure you follow the YAML code indentation standards. The suggested syntax for YAML files is to use 2 spaces for indentation, do not use TABS. If the indentation and syntax are incorrect, the changes will not work.

As seen in the file, DHCP is available and the server is getting the IP address from the DHCP server. To change your server IP address, for example to 192.168.1.100, let’s back up the file /etc/netplan/00-installer-config.yaml
and open the file
to replace the content of /etc/netplan/00-installer-config.yaml above with these lines.
When editing the file, make sure the ethernet interface match with the one we see when invoking the ‘ip a’ or ‘ip link’ command.
To check the new configuration file without applying the changes, we can run this command:
If everything is okay, you will see a message as seen in the picture below. You can hit ENTER to accept the changes or leave it to revert the changes back to the previous configuration.

Configure Static IP Address on Ubuntu Desktop 20.04
Most modern home routers have configuration options to allow you to reserve an IP address for a specific device connected to the same network. With this option in your home router, your devices on the network will get static/fixed IP addresses. This is the easiest and most recommended way to assign an IP address to your device, and this is called static DHCP or DHCP reservation.
If you do not want to configure it on the router, you can do it on the device itself. At this moment, we will show you how to configure a static IP address on Ubuntu desktop 20.04. Let’s click on the network icon on the top right of your screen.

Clicking the icon will bring you to the new window, as seen in the picture below
Now just $ 43 .99 /mo

In this example, we will configure the static IP address for the wired connection. So, we need to click on the cog icon next to the on-off slider in the wired connection section. To configure your WiFi connection, then you need to click on the cog icon in the WiFi connection section.
This will open a new window, click on the IPv4 as shown in the picture below

In the next window, choose “Manual” in IPv4 Method and fill the following information in the forms

You can leave the DNS part blank if you want to set it to automatic or use your own DNS address, separate the IP addresses with commas, for example, 1.1.1.1, 8.8.8.8 , then click on the APPLY button above.
Congratulations! you have successfully configured a static IP address on Ubuntu 20.04.
Of course, you don’t need to configure a static IP address on Ubuntu 20.04 yourself if you use one of our Linux VPS Hosting services and have additional IP addresses. In which case you can simply ask our expert Linux admins to configure and set this up for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post on How To Configure a Static IP Address on Ubuntu 20.04, please share it with your friends on social networks, or simply leave a reply below. Thanks.
Leave a Comment Cancel reply
Save my name, email, and website in this browser for the next time I comment.
Yes, add me to your new blog post notifications list
Content Hub
Other services, managed hosting, linux vps hosting, apps hosting.
Terms of Service and other policies Residents of California: Do not sell my personal information
© 2001-2023 Rose Web Services LLC.
How to Set Static IP Address on Ubuntu Server 22.04
In this post, we will cover how to set static ip address on Ubuntu server 22.04.
It is highly recommended to have a static ip on linux server because it would be persistent across the reboot. Static IP plays an important role for servers like Mail Server, Web Server and File server etc.
Prerequisites
- Minimal Installed Ubuntu Server 22.04
- Regular User with sudo admin rights
In Ubuntu server 22.04, networking is controlled by netplan utility , so we will use netplan to configure static ip address on Ubuntu server.
Note: we cannot use nmcli utiltity as it is not the part of default installation on Ubuntu server.
Setting up Static IP address on Ubuntu Server 22.04
Login to your Ubuntu server 22.04, look for the netplan configuration file. It is located under /etc/netplan directory.
Run below cat command to view the contents of ‘00-installer-config.yaml’
Note: Name of configuration file may differ as your per setup. As it is an yaml file, so make sure to maintain the indentation and syntax while editing.
As per above output, it says that we have ens33 interface and it is getting ip from dhcp server. Alternate way to view interface name is via ip command.
Now, to configure static ip in place of dhcp, edit netplan configuration file using vi or nano editor and add the following content.
save and close the file.
In the above file we have used following,
- ens33 is the interface name
- addresses are used to set the static ip
- nameservers used to specify the DNS server ips
- routes used to specify the default gateway
Note: Change the IP details and interface name as per your environment.
To make above changes into the effect the apply these changes using following netplan command,
Run following ip command to view the ip address on interface,
To view the default route, run
Output of above commands,
Perfect, above commands’ output confirms that static ip and route has been configured successfully.
That’s all from this post. Kindly do post your queries and feedback in below comments section.
4 thoughts on “How to Set Static IP Address on Ubuntu Server 22.04”
How do I use Netplan to set up a static IP address on WIFI?
change the network device “ens33” to something else, it will be listed when you run “ip a”; it;s probably wlan0 but that’s not guaranteed.
there will be a config file for the wifi interface. look for something like 00-installer-config-wifi.yaml
Hey! thanks I had problems before setting up the DNS and none config would work! This one did and you made this post really simple to follow!
Leave a Comment Cancel reply

How to Set Static IP Address on Ubuntu Linux
On Ubuntu 18.04 and later versions, there is a new way to set an IP address i.e., Netplan . This tutorial describes how to set an IP address from the command line on Ubuntu Linux by using the Netplan utility.
Set an IP Address with Netplan on Ubuntu
Netplan is the new way to set an IP address on newer versions of Ubuntu ( Ubuntu 18.04 and later.) With netplan , network configurations are consolidated and saved under /etc/netplan with a .yaml extension.
Firstly, run the command below to change into the netplan directory and then list the contents of the netplan directory as follows.
You should see the default Netplan configuration file. Mine is named 01-network-manager-all.yaml on my Ubuntu 20.04 machine. Yours might be named something slightly different, depending on your Ubuntu version.

It is advisable to create a backup of the default netplan configuration file as follows.
Next, run the command below to confirm the name of the network interface for which you want to set an IP address.

In this example, I am working with network interface eth0 .
Configure IP Address in Ubuntu
Now, open the default Netplan configuration file for editing with the command below.
You would need to make changes to the file so that it looks similar to what you see in the image below. In my case, the new additions are marked with a red border.

Note : Proper indentation is important when working with YAML configurations. You do not have to use the exact same spacing in my example above. You may choose to use a fixed number of spaces for each level of indentation.
Save and close the configuration file.
Next, run the following command to check for syntax errors in the Netplan configurations.

When prompted, press enter to accept the configuration. If the configuration is accepted, you are on course. Otherwise, review your configuration and test again.
Apply Netplan and Verify IP Address
Finally, apply your Netplan configurations with the command below.
You may now verify your updated network settings as follows.

In this tutorial, we described the steps to set an IP address on Ubuntu by using the Netplan utility. We hope that you find this very helpful.
Tutorial Feedback...
Recommended articles.
How to Find Network MAC Address in Linux System
How to Change Network MAC Address in Linux
How to Set a Static IP Address in CentOS Linux
How to Check Linux Network Statistics from Command Line
How to Check a Port is Open on a Remote Linux System
Got Something to Say? Join the Discussion... Cancel reply
Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.
Save my name, email, and website in this browser for the next time I comment.
Don't subscribe All Replies to my comments Notify me of followup comments via e-mail. You can also subscribe without commenting.

IMAGES
VIDEO
COMMENTS
After gathering your connection name, subnet mask, and default gateway, you can set a static IP address in the terminal using the nmcli command. Or, in the GNOME desktop, open your connection settings and click the + icon, then enter the info for your static IP address there.
Setting up a static IP address on Ubuntu Desktop computers requires no technical knowledge. In the Activities screen, search for "settings" and click on the icon. This will open the GNOME settings window. Depending on the interface you want to modify, click either on the Network or Wi-Fi tab.
You need to set a static IP address on your Ubuntu system to avoid problems. Step 1: Identify the correct network interface The first step is always to know the name of your network interface. "But why?" you might ask. That is because since Ubuntu 20.04, the network interfaces are named using predictable network interface names.
Ubuntu 12.04 - 17.04 (incl. Ubuntu 16.04 LTS) Step 1: Configure the network interface Step 2: Configure the DNS servers Step 3: Restart networking Configure the Hostname This tutorial explains how to set up a static IP address on an Ubuntu system from the command line.
Add a comment. 63. Setting the static IP address as above in the accepted answer here works, but one has to flush the old IP addr setting and then restart networking.service: sudo ip addr flush enp0s25 sudo systemctl restart networking.service. Then verify it is correct: ip add.
Method 1: Assign static IP in Ubuntu using command line Note for desktop users: Use static IP only when you need it. Automatic IP saves you a lot of headache in handling network configuration. Step 1: Get the name of network interface and the default gateway
How to Set a Static IP Using the Command Line In this section, we will explore all the steps in detail needed to configure a static IP. Step 1: Launch the terminal You can launch the terminal using the shortcut Ctrl+ Shift+t. Step 2: Note information about the current network
How to Set Static IP Address On Ubuntu Desktop To get started, Launch ' Settings ' from the application menu as shown. Ubuntu Settings On the window that appears, click on the ' Network ' tab at the left sidebar and then hit the gear icon on the network interface that you wish to configure. In my case, I'm configuring my wired interface.
You can easily make Ubuntu static IP settings using the netplan command in 22.04 LTS and 22.10 versions. To do this, follow the steps below. First, find out the name of your network interface using the command below: sudo ip a What you see here is your network interface name. This name may be different on each device.
Set Your Static IP in Ubuntu Set Your Static IP in CentOS Using the ip Command ifconfig is being replaced by the ip command. Configuring a static IP can be difficult in Linux because it's different based on the distro and version you're using. This guide will show you how to configure a static IP address on the most popular Linux distros. Ubuntu
Wi-Fi Access Points. To assign a static IP address or Wi-Fi interface, click on the gear icon on the Wi-Fi interface page and then IPv4 tab >> Manual >> Enter IP address, Netmask, Gateway, DNS (Toggle to disable Automatic DNS configuration) >> Apply. Set IP for Wired Wi-Fi. Finally, disable and enable the Wi-Fi interface to apply the IP address.
To configure static IP address in RHEL / CentOS / Fedora, you will need to edit: /etc/sysconfig/network /etc/sysconfig/network-scripts/ifcfg-eth0 Where in the above "ifcfg-eth0" answers to your network interface eth0. If your interface is named " eth1" then the file that you will need to edit is "ifcfg-eth1". Let's start with the first file:
The ip command is available on most Linux distributions. For setting an IP address, use it like this: ip addr add [ip_address] dev [interface] For example, add an IP address to the eth1 interface as: sudo ip addr add 192.168.56.21/24 dev eth1 You now have two IP addresses: one from the old configuration and one from the new command:
A static IP address allows you to manually select your IP address by configuring it on the Linux system, whereas DHCP relies on the router or DHCP server to lease you an IP address - either a reserved one or the next available one that is currently free, depending on the setup. In this tutorial you will learn how to:
Change IP address on Ubuntu Server Change to Static IP Address Changing to a static IP address will allow you to manually choose an IP address on Ubuntu Server. On the other hand, using DHCP leaves it up to the router or DHCP server's configuration to choose which IP address your machine will have.
Configure Static IP Address on Ubuntu Desktop 20.04 Most modern home routers have configuration options to allow you to reserve an IP address for a specific device connected to the same network. With this option in your home router, your devices on the network will get static/fixed IP addresses.
Setting up Static IP address on Ubuntu Server 22.04 Login to your Ubuntu server 22.04, look for the netplan configuration file. It is located under /etc/netplan directory. $ cd /etc/netplan/ $ ls -l total 4 -rw-r--r-- 1 root root 116 Oct 12 04:03 00-installer-config.yaml $ Run below cat command to view the contents of '00-installer-config.yaml'
In "IPV4" Method" section, select "Manual" and enter your static IP address, Netmask and Gateway. Once done, click on the "Apply" button. Now that you have set up a static IP Address, open your terminal either by using the Ctrl+Alt+T keyboard shortcut or by clicking on the terminal icon and verify the changes by typing: ip addr
Setting a Static IP in Ubuntu - Linux IP Address Tutorial. When it comes to Deep Learning, I think nobody symbolizes the field better than Goeffrey Hinton, the father of Deep Learning.
Firstly, run the command below to change into the netplan directory and then list the contents of the netplan directory as follows. $ sudo cd /etc/netplan $ ls You should see the default Netplan configuration file. Mine is named 01-network-manager-all.yaml on my Ubuntu 20.04 machine.