Tecmint: Linux Howtos, Tutorials & Guides

A Beginner-Friendly Guide for Linux / Start Learning Linux Quickly...

How to configure static ip address on ubuntu 20.04.

Usually, when a client system connects to a network via WiFi or an ethernet cable, it automatically picks an IP address from the router. This is made possible through the DHCP server which auto-assigns IP addresses to clients from a pool of addresses.

The drawback with DHCP is that once the DHCP lease time has lapsed, the IP address of a system changes to a different one, and this leads to a disconnection in case the system was used for a particular service such as a file server. For this reason, you may want to set a static IP address so that it never changes even when the lease time is up.

In this guide, you will learn how to configure a static IP address on Ubuntu 20.04 server and desktop.

Network Configuration

Ubuntu uses the NetworkManager daemon for managing network configuration. You can configure a static IP either graphically or on the command line.

For this guide, we will focus on setting a static IP address using both the GUI and on the command line, and here is the IP configuration:

This information will be different for you, so replace the values accordingly according to your subnet.

On this page

  • Set Static IP Address on Ubuntu 20.04 Desktop
  • Set Static IP Address on Ubuntu 20.04 Server

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.

Ubuntu Network

In the new window that appears, your interface’s network settings will be displayed as shown. By default, the IP address is set to use DHCP to automatically pick an IP address from the Router or any other DHCP server.

In our case, the current IP address assigned is 192.168.2.104 .

Ubuntu Network Configuration

Now select the IPv4 tab to start setting the static IP address. As you can see, the IP addressing is set to Automatic (DHCP) by default.

Ubuntu Network Method

Click on the ‘ Manual ’ option and new address fields will be displayed. Fill out your preferred static IP address, netmask, and default gateway.

Set Manual Network

The DNS is also set to automatic. To manually configure the DNS, click on the toggle to turn off Automatic DNS. Then provide your preferred DNS entries separated by a comma as shown.

Set Network DNS

Once all is done, click on the ‘ Apply ’ button at the top right corner of the window. For the changes to apply, restart the network interface by clicking on the toggle to disable it and enable it again.

Enable Network Connection

Once again, click on the gear icon to reveal the new IP configuration as shown.

Verify Network Configuration

You can also confirm the IP address on the terminal by running the ifconfig or ip addr command .

Check IP Address

To confirm the DNS servers, run the command:

Check DNS Servers

How to Set Static IP Address on Ubuntu Server Using Netplan

We have seen how we can configure a static IP address graphically on Ubuntu 20.04 desktop. The other option is configuring a static IP address on the terminal using Netplan .

Developed by Canonical, Netplan is a command-line utility used to configure networking on modern Ubuntu distributions. Netplan makes use of YAML files to configure network interfaces. You can configure an interface to acquire an IP dynamically using DHCP protocol or set a static IP.

Open your terminal and head over to the /etc/netplan directory. You will find a YAML configuration file which you will use to configure the IP address.

In my case the YAML file is 01-network-manager-all.yaml with the default settings as shown.

Netplan YAML File

For the Ubuntu server, the YAML file is 00-installer-config.yaml and these are the default settings.

Default Network Settings

To configure a static IP, copy and paste the configuration below. Be mindful of the spacing in the YAML file.

Next, save the file and run the netplan command below to save the changes.

You can thereafter confirm the IP address of your network interface using the ifconfig command .

Check Ubuntu Server IP Address

This wraps up today’s article. We hope you are now in a position to configure a static IP address on your Ubuntu 20.04 desktop & server system.

Previous article:

Next article:

Photo of author

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Related Posts

Linux IP Address

A Beginner’s Guide to Configuring IPv4 and IPv6 Addresses in Linux

Differences Between IPv4 and IPv6

What’s Wrong with IPv4 and Why We Are Moving to IPv6

Linux Network Information Tool

What IP – A Network Information Tool for Linux

Configure Network Interface in CentOS 7

How to Configure Network Static IP Address on RHEL/CentOS 8/7

Create NIC Teaming in CentOS

How to Create NIC Teaming or Bonding in CentOS 8 / RHEL 8

Auto Start Services on Linux Boot

How to Configure Network Services to Auto Start on Boot

21 thoughts on “How to Configure Static IP Address on Ubuntu 20.04”

DHCP is that once the DHCP lease time has lapsed, the IP address of a system changes to a different one, and this leads to a disconnection in case the system was used for a particular service such as a file server.

For this reason, you may want to set a static IP address so that it never changes even when the lease time is up.

Got something to say? Join the discussion. Cancel reply

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.

Save my name, email, and website in this browser for the next time I comment.

Notify me of followup comments via e-mail. You can also subscribe without commenting.

How-To Geek

How to set a static ip address in ubuntu.

When static is the way forward.

Quick Links

What is a static ip address, setting a static ip in ubuntu, set a static ip in ubuntu with the gui, connection convenience, key takeaways.

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.

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.

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 .

Related: Static IP vs. Dynamic IP: What Is the Difference?

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 .

Nmcli is the command-line  network manager tool , and can be used to change your IP address, configure network devices, and --- relevant to our purposes --- set up a static IP in Ubuntu.

We're demonstrating this technique on Ubuntu 22.04 LTS, but it ought to work on any Linux distribution, including Ubuntu 23.04. The nmcli 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

command with the

nmcli connection show

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           UUID TYPE DEVICE

netplan-enp0s3 1eef7e45-3b9d-3043-bee3-fc5925c90273 ethernet enp0s3

  • 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.

Related: How to Calculate Subnet Masks on Linux With ipcalc

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 the current IP address assigned to the Ubuntu system. 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.

ping 192.168.86.128

Even if another device had previously used that IP address, it'll be given a new IP address when it next boots up. Nothing responds to the ping requests, so we're clear to go ahead and configure 192.168.86.128 as our new static IP.

Related: How to Set the Default Gateway in Linux

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.

sudo nmcli con add con-name "static-ip" ifname enp0s3 type ethernet ip4 192.168.86.128/24 gw4 192.168.86.1

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 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.

nmcli con mod "static-ip" ipv4.dns "8.8.8.8,8.8.4.4"

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."

nmcli con mod "static-ip" ipv4.method manual

And now we can start or "bring up" our new connection.

nmcli con up "static-ip" ifname enp0s3

We didn't get any error messages which is great. Lets use nmcli to look at our connections once more.

nmcli con show

Here's the output:

NAME UUID TYPE DEVICE

static-ip da681e18-ce9c-4456-967b-63a59c493374 ethernet enp0s3

netplan-enp0s3 1eef7e45-3b9d-3043-bee3-fc5925c90273 ethernet --

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.

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.  Click the "Wired Settings" or "Wi-Fi Settings" menu option. The details of the active connection are displayed.

If you followed our previous instructions the new connection will be the active connection. We can see our new "static-ip" connection has the IP address, default gateway, and DNS servers that we set for it.

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 our new static IP 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.

You can swap between the available connections by clicking directly on their names.

If you want to modify a connection after you create it, click the cog icon. In this case, we'll 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.

Related: How to Assign a Static IP Address in Windows 10 or Windows 11

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 Configure Static IP Address on Ubuntu 20.04

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.

configuring static ip address on ubuntu 20.04

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’.

how to set up static ip address on ubuntu 20.04

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.

configure static ip address on ubuntu 20.04

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.

set up and configure static up address on ubuntu 20.04

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.

ip address configuration on ubuntu 20.04

Clicking the icon will bring you to the new window, as seen in the picture below

Now just  $ 43 .99 /mo

configuring a static ip address on ubuntu 20.04

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

how to configure and set up a static ip address on ubuntu 20.04

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

setting up static ip address on an ubuntu 20.04

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

Save my name, email, and website in this browser for the next time I comment.

How to Assign Static IP Address on Ubuntu 20.04 LTS

It is always recommended to assign a static IP address to a Linux system because static ip address will be persistent across the reboots. Recently canonical has released its stable operating system “ Ubuntu 20.04 LTS (Focal Fossa) ” for both desktop and servers. In this article we will demonstrate how to assign a static ip address on Ubuntu 20.04 LTS Server and desktop.

Assign Static IP Address On Ubuntu 20.04 LTS Server

In Ubuntu 20.04 LTS server, network configuration is controlled and managed by netplan utility. But during the installation, cloud-init configure a dynamic ip to interface on server if the dhcp server is available. so, to configure a static ip, first we must make sure and confirm that network interface is not managed by cloud-init.

Open cloud-init file “ /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg ” and make sure entry “ network: {config: disabled} ” is there. In case this entry is missing, then add it manually.

Use “ ip addr show ” command from the console to view ip address,

ip-addr-show-dynamic-ip-ubuntu-20-04-server

As we can see above, a dynamic ip is assigned automatically on interface card “ enp0s3 ”. So, to make this ip address static, we must edit the netplan configuration file “ /etc/netplan/00-installer-config.yaml ”.

Above are the default entries, which shows that interface “ enp0s3 ” is getting the IP from DHCP server. As it is an yaml file, so while making the changes in the file we must follow correct indentation. Add the following lines to the yaml file,

save and close the file.

Updated-netplan-yaml-ubuntu-20-04-server

Run the following “ netplan apply ” command to make the above changes into the effect.

Now run “ ip addr show ” and “ ip route show ” command to view ip address and route details.

Output of above command would look like below,

ip-addr-show-route-ubuntu-20-04-server

Perfect, output confirms that Static IP has been assigned successfully on interface ‘ enp0s3 ‘. Even if we reboot the server, this ip address will be consistent.

Now, let’s move to Ubuntu 20.04 LTS desktop.

Assign Static IP Address on Ubuntu 20.04 LTS Desktop

Network configuration in Ubuntu desktop is controlled by network manager. Configuring a static ip address on Ubuntu 20.04 desktop is very easy. Login to your desktop environment and click on network icon and then choose wired settings .

network-icon-ubuntu-20-04-lts-desktop

In the next window, Click on ‘ gear box ’ icon under wired option,

Gear-box-icon-Ubuntu-network-icon

In the next window, Choose IPV4 Tab and then select Manual and specify the IP details like IP address, netmask, gateway and DNS Server IP.

Static-IP-Ubuntu-20-04-LTS-Desktop

Click on Apply to save these changes and we must disable and enable interface once to assign the ip address to interface.

Once you enable and disable the interface then static IP should be assigned to the interface, we can verify by looking at the Details Tab from Wired Settings .

IP-Details-Ubuntu-Desktop-Ubuntu-20-04-LTS

Perfect, above confirms that static ip address has been assigned to the interface successfully. This conclude the article; I hope these steps help you to configure static IP Address on your Ubuntu 20.04 LTS server and desktop. Please do share your feedback and comments.

12 thoughts on “How to Assign Static IP Address on Ubuntu 20.04 LTS”

Thanks for the excellent article, It is always recommended to assign a static IP address to a Linux system because static ip address will be persistent across the reboots. that is understood. where exactly i see the advantage of assigning static ip address to my linux desktop? How circled point 3, 4, 5 in IPv4 tab are assigned, especially entries 192.168.1.210 and 255.255.255.0. If these two are explained, then it will be great.

ok, ifconfig and netstat -r gives netmask and gateway. but still i would like to know the advantage of assigning static ip address to my linux desktop preferably with example applications. thanks.

Imagine you open a network service on your linux desktop, let’s assume it is a web server running on port 80, and you want to expose this service to the internet.

You would have to add a port translation rule into your internet box to forward connections on your public ip to your linux desktop system. And the configuration in the box is static, you need a fixed and consistent ip addr on your internal network.

You achieve that either with static ip that you assign by yourself, or by configuring the dhcp server inside your internet box to reserve an ip associated to your linux destop mac address.

Hi Narayan, If your desktop is connected to the modem or a switch where DHCP server is configured with subnet “192.168.1.0/24”. So when your desktop tries to get ip from DHCP server then it will always picks one ip from the pool “192.168.1.2 – 192.168.1.254” . But if you want to map a fixed ip to desktop then you can assign that IP as static.

$ip addr show just hung my SSH session. I don’t know how long it will take to time out.

nice but i cannot follow your tutorial cause i just using phone Hehe

Thank You Very Much My Problem has fixed now All credit goes to you 🙂

Hello, I’m running ubuntu server 20.04 on a hyper-v environment, i did all steps in the page, but when I want to run update, can´t connect to internet. Please help.

I got the same problem. I’m running ubuntu 20.04 on virtualbox. I fixed it by changing the “gateway4: 192.168.1.1” to “gateway4: 192.168.0.1”. Flipping the 1 to a 0, or to the same number as the one in my own ip in that place. Happy debugging!

Thanks for the good informations…

Useful article. I am using usb broadband modem and for my case it was also useful to use such command to find out default gateway $ ip route | grep default It has given: default via 10.1.1.3

I saw this link at askubuntu.com I was having issue statically assigning IP in ubuntu and after following your steps it worked. Thanks so much and keep it up

Leave a Comment Cancel reply

Stack Exchange Network

Stack Exchange network consists of 183 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 server 20.04?

I tried editing /etc/network/interfaces but the file is empty I also tried using nmtui to edit the network configurations but it shows that there are no configurations set at all. Can anyone help?

Liraz Shalom's user avatar

  • This article found with a quick google search shows and tells you how to set a static IP –  David Mar 27, 2021 at 10:10

2 Answers 2

You set it in /etc/netplan/ it's quite easy. I wrote about it here .

Pablo Bianchi's user avatar

  • You should include the steps here, and not just link to the article. –  Artur Meinild Mar 30, 2021 at 8:57
  • gateway4 is long deprecated and steps are not here. Down –  Sam Jan 9 at 22:06

Static ip can be set in network settings in Ubuntu, see this .

Oppili's user avatar

  • OP is related to Ubuntu Server –  Pablo Bianchi May 12, 2021 at 4:45

You must log in to answer this question.

Not the answer you're looking for browse other questions tagged networking server 20.04 ..

  • The Overflow Blog
  • Build vs. buy doesn't matter. Tool adoption does. sponsored post
  • CEO update: Giving thanks and building upon our product & engineering foundation
  • Featured on Meta
  • Update: New Colors Launched
  • Incident update and uptime reporting
  • Ubuntu 23.10 is now on-topic!
  • AI-generated content is not permitted on Ask Ubuntu
  • Notifying users about the policy on AU concerning AI-generated content

Hot Network Questions

  • Contacting Academic about Industry Problem
  • What happens when Goose, or her species, swallow people?
  • Can You Transport a Brick House with Only Drawmij's Instant Summons?
  • Creating buffers to closest distances with two categories
  • Convert black and white pictures into color images
  • "Rock Paper Scissors" game
  • Why is "cum" used in this sentence from "De Bello Gallico"?
  • How to compare influence of outlier in regression model. ANOVA of two models in R
  • How to maintain NAV (Net Asset Value) for family fund
  • Image Processing Application in C
  • Problem with push pull output
  • Two cats and one dog (were/was)
  • Who is the third Kang variant in this image?
  • Would Summoning an Object Inscribed with Glyphs of Warding Via Drawmij's Instant Summons Invalidate the Glyphs?
  • Is it illegal for King Charles not to vote in Australia?
  • Husband has dual citizenship Canada & UK. We reside in the UK. Will India let him in?
  • Did God forsake Jesus while on the cross?
  • Is "Mutually Assured Destruction" still valid considering so many conventional missiles are currently getting shot down?
  • Zassenhaus's Butterfly Lemma
  • Relationship between bel and decibel
  • Can I write "paper accepted without revisions" on a CV?
  • How many random bits does this algorithm use on average?
  • Need help with parsing NWS JSON weather alerts causing reset on ESP8266
  • Is it legal to bribe a private eye?

how to set static ip address in ubuntu 20 04

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 .

  • Advertising
  • Privacy Policy
  • Become an Author

Logo

How to set a Static IP address on Ubuntu 20.04?

IP address

A server usually always has a static IP address that facilitates the rest of the network services. So although it is not mandatory if it is of great help for the management of the server. So this post is about how to define a static IP address in Ubuntu 20.04

A Static IP address

An IP address is an identifier held by each device that connects to the Internet or a computer network. In the case of the Internet, it must be unique to avoid connection conflicts.

On the one hand, there are dynamic IP addresses that change their value from time to time. Normally, these addresses are assigned by a DCHP server . The sysadmin does not have to worry about the assigned address as they are renewed from time to time.

On the other hand, we have static or fixed IP addresses, which unlike dynamical ones, do not change over time. In this case, it must be assigned and configured manually in the system.

Each of them has its own advantages, however, for internal networks, it is convenient to have equipment with static IP addresses. This facilitates the administration and routing of packets within the network. It is also easier to maintain the network.

So, let us work!

How to set up a static IP address on Ubuntu 20.04?

Before starting the work, it is necessary to know which is the network interface to which we want to assign the static IP address. To do this, execute the following command:

1.- Check the current IP address on Ubuntu 20.04

As you can see in the image, I only have a network interface called enp0s3 whose IP address is 192.168.250.8 but it was assigned with DHCP. So I’m going to assign it the static IP address 192.168.250.20

In Ubuntu the network configuration is done by netplan where the configurations are written in yml format.

So, before modifying the configuration file, it is convenient to make a backup of this file to prevent problems.

And now you can modify the file with the help of nano.

You will see the following content:

Then modify it to look like this:

2.- Set a static IP address on Ubuntu 20.04

I think the options are very easy to understand but I will explain it to you anyway:

  • dhcp4: it is not so that the interface does not use DHCP and only uses the IP address we set.
  • addresses: The IP address that we are going to define.
  • gateway4: The gateway of the network
  • nameservers: the DNS servers that the computer will use.

Then save the changes and close the file. Remember that the file is in yml format so it respects the rules and syntax so it does not give any error.

To apply the changes, execute the following command:

And check the changes with the following command:

3.- Static IP address on Ubuntu 20.04

As you can see, everything went well.

Setting a static IP address to Ubuntu 20.04 is quite simple even from the terminal. With this you will be able to manage your server or computer within a network more easily.

Please share this post and join our Telegram channel .

Watch out for the indentation error you made in the 00-installer-config.yaml. Should look like this: “” dhcp4: no addresses: – 192.168.121.199/24 gateway4: 192.168.121.1 nameservers: addresses: [8.8.8.8, 1.1.1.1] “

simple & short,

thank you very much.

I don’t have a 00-installer-config.yaml file in my /etc/netplan directory. I only have a 01-network-manager-all.yaml file which does not have the same content. ???

Thanks, Been a while since I had to use change the ip in Ubuntu. Things changed 🙂

LEAVE A REPLY Cancel reply

Save my name, email, and website in this browser for the next time I comment.

Latest article

How to block advertising on android using dns, how to create multiple users in android 14, how to use opera free vpn on your android device.

Osradar

For my network, the current adapter is eth0 . It could be different for your system

  • Note the current network adapter name

As my current adapter is eth0 , the below details are relevant.

It is worth noting that the current IP 172.23.199.129 is dynamically assigned. It has 20 bits reserved for the netmask. The broadcast address is 172.23.207.255 .

  • Note the subnet

We can find the subnet mask details using the command below:

Select the output against your adapter and read it carefully.

image-15

Based on the class and subnet mask, the usable host IP range for my network is: 172.23.192.1 - 172.23.207.254 .

Subnetting is a vast topic. For more info on subnetting and your usable IP ranges, check out this article .

Step 3: Make configuration changes

Netplan is the default network management tool for the latest Ubuntu versions. Configuration files for Netplan are written using YAML and end with the extension .yaml .

Note: Be careful about spaces in the configuration file as they are part of the syntax. Without proper indentation, the file won't be read properly.

  • Go to the netplan directory located at /etc/netplan .

ls into the /etc/netplan directory.

If you do not see any files, you can create one. The name could be anything, but by convention, it should start with a number like 01- and end with .yaml . The number sets the priority if you have more than one configuration file.

I'll create a file named 01-network-manager-all.yaml .

Let's add these lines to the file. We'll build the file step by step.

The top-level node in a Netplan configuration file is a network: mapping that contains version: 2 (means that it is using network definition version 2).

Next, we'll add a renderer, that controls the overall network. The renderer is systemd-networkd by default, but we'll set it to NetworkManager .

Now, our file looks like this:

Next, we'll add ethernets and refer to the network adapter name we looked for earlier in step#2. Other device types supported are modems: , wifis: , or bridges: .

As we are setting a static IP and we do not want to dynamically assign an IP to this network adapter, we'll set dhcp4 to no .

Now we'll specify the specific static IP we noted in step #2 depending on our subnet and the usable IP range. It was 172.23.207.254 .

Next, we'll specify the gateway, which is the router or network device that assigns the IP addresses. Mine is on 192.168.1.1 .

Next, we'll define nameservers . This is where you define a DNS server or a second DNS server. Here the first value is   8.8.8.8 which is Google's primary DNS server and the second value is 8.8.8.4 which is Google's secondary DNS server. These values can vary depending on your requirements.

Step 4: Apply and test the changes

We can test the changes first before permanently applying them using this command:

If there are no errors, it will ask if you want to apply these settings.

Now, finally, test the changes with the command ip a and you'll see that the static IP has been applied.

image-17

How to Set a Static IP Using the GUI

It is very easy to set a static IP through the Ubuntu GUI/ Desktop. Here are the steps:

  • Search for settings .
  • Click on either Network or Wi-Fi tab, depending on the interface you would like to modify.
  • To open the interface settings, click on the gear icon next to the interface name.
  • Select “Manual” in the IPV4 tab and enter your static IP address, Netmask and Gateway.
  • Click on the Apply button.

image-16

  • Verify by using the command ip a

image-18

In this article, we covered two methods to set the static IP in Ubuntu. I hope you found the article useful.

What’s your favorite thing you learned from this tutorial? Let me know on Twitter !

You can read my other posts here .

I am a DevOps Consultant and writer at FreeCodeCamp. I aim to provide easy and to-the-point content for Techies!

If you read this far, thank the author to show them you care. Say Thanks

Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started

  • IT Management
  • Infrastructure
  • High Performance

LinuxToday

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. Here’s how to set a static IP address on your Ubuntu 20.04 install.

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends, & analysis

Two Methods to Install Slack on Debian 12 Bookworm

Top 8 torrent clients for ubuntu & other linux distributions, fwupd 1.9.8 brings support for uswid sbom data with lzma compressed payloads, freebsd 14 release: best new features, lubuntu 22.04 lts users can now install the lxqt 1.4 desktop, here’s how.

LinuxToday is a trusted, contributor-driven news resource supporting all types of Linux users. Our thriving international community engages with us through social media and frequent content contributions aimed at solving problems ranging from personal computing to enterprise-level IT operations. LinuxToday serves as a home for a community that struggles to find comparable information elsewhere on the web.

  • Privacy Policy
  • California – Do Not Sell My Information

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.

logo

How to set a static ip address in Ubuntu Server 20.04

When you install Ubuntu server, its network setting defaults to dynamic IP addressing, that is, the network management daemon in Ubuntu searches for a DHCP server on the connected network and configures the network with the IP address assigned by DHCP. Even when you start an instance in the cloud, the network is configured with dynamic addressing using the DHCP server setup by the cloud service provider. In this chapter, you will learn how to configure the network interface with static IP assignment.

Follow these steps to connect to the network with a static IP:

Step 1 : Open /etc/netplan/50-cloud-init.yaml and find the following lines:

how to set static ip address in ubuntu 20 04

Step 2 : Change the preceding lines to add an IP address, net mask, and default gateway (replace samples with the respective values):

how to set static ip address in ubuntu 20 04

Step 3 : Then run sudo netplan apply

how to set static ip address in ubuntu 20 04

Step 4 : Try to ping a remote host to test the network connection

Recommended

how to set static ip address in ubuntu 20 04

How to Install and Use Podman on Ubuntu 22.04

18 days ago

how to set static ip address in ubuntu 20 04

How To Install Docker on Ubuntu 22.04

19 days ago

how to set static ip address in ubuntu 20 04

How To Use Apache as a Reverse Proxy with mod_proxy on Ubuntu 22.04

3 months ago

how to set static ip address in ubuntu 20 04

How To Set Up Password Authentication with Apache on Ubuntu 22.04

how to set static ip address in ubuntu 20 04

How to Install Let's Encrypt SSL with Apache on Ubuntu 22.04

how to set static ip address in ubuntu 20 04

How to Configure SSL for Apache on Ubuntu 22.04

how to set static ip address in ubuntu 20 04

How to set up Apache virtual host on Ubuntu 22.04

how to set static ip address in ubuntu 20 04

How to Install PHP 8.3 on Ubuntu 22.04

how to set static ip address in ubuntu 20 04

How to Install PHP 8.2 on Ubuntu 22.04

how to set static ip address in ubuntu 20 04

How to Install PHP 8.0 on Ubuntu 22.04

how to set static ip address in ubuntu 20 04

How to Install PHP 7.4 on Ubuntu 22.04

how to set static ip address in ubuntu 20 04

How to Install PHP 7.2 on Ubuntu 22.04

how to set static ip address in ubuntu 20 04

How to Install vsftpd FTP Server on Ubuntu 22.04

4 months ago

how to set static ip address in ubuntu 20 04

How to Setup SFTP Server on Ubuntu 22.04

how to set static ip address in ubuntu 20 04

How to Install and Use rsync on ubuntu 22.04

Press ESC to close

How to Set Static IP on Ubuntu 20.04 (Desktop) Focal Fossa static ip ubuntu ubuntu 20.04

How to Set Static IP on Ubuntu 20.04 (Desktop)

Written by Rahul , Updated on April 26, 2020

Question – How do I set a static IP Address on Ubuntu 20.04 LTS Desktop systems? Steps to set the static IP address on your Ubuntu Desktop system

Ubuntu 20.04 systems uses netplan from the previous LTS system. The desktop systems provides an attractive graphical user interface to work with it. Using the GUI, you can easily change or set a static IP address on your Ubuntu system.

Set A Static IP on Ubuntu 20.04

You must have root or sudo privileged account account to the Ubuntu system. Login to your Ubuntu 20.04 Desktop system. After that open settings on your machine as shown in the below screenshot.

How to Set Static IP on Ubuntu 20.04 (Desktop) Focal Fossa static ip ubuntu ubuntu 20.04

In the settings window, click on Network tab in the left sidebar. After that click icon to open setting for your systems network interface as shown in the below screen.

How to Set Static IP on Ubuntu 20.04 (Desktop) Focal Fossa static ip ubuntu ubuntu 20.04

This window will show you the current IP address configured on your system.

Now select the IPv4 tab Then under the IPv4 Method select the “ Manual ” option. In the Addresses section and set your IP Address, Netmask, and Gateway. You may also set remote DNS IP addresses. If you don’t know what to set here use 8.8.8.8 and 8.8.4.4 as shown in below screenshot.

How to Set Static IP on Ubuntu 20.04 (Desktop) Focal Fossa static ip ubuntu ubuntu 20.04

View Current IPs on Ubuntu

You can view the current static IP under the details tab.

How to Set Static IP on Ubuntu 20.04 (Desktop) Focal Fossa static ip ubuntu ubuntu 20.04

To view IP on command line. Press CTRL ALT T to launch the terminal on your Ubuntu system. Then type the following command to view all IP addresses configured on your system.

How to Set Static IP on Ubuntu 20.04 (Desktop) Focal Fossa static ip ubuntu ubuntu 20.04

Share Article:

You might also like.

How to Install Prestashop on Ubuntu 22.04 ubuntu

How to Install Prestashop on Ubuntu 22.04

How to Install SysPass Password Manager on Ubuntu 22.04 linux ubuntu

How to Install SysPass Password Manager on Ubuntu 22.04

How to Install Harbor Docker Image Registry on Ubuntu 22.04 ubuntu

How to Install Harbor Docker Image Registry on Ubuntu 22.04

Other stories, install egroupware ce on centos 7 / centos 8, how to check ip address on ubuntu 20.04 (desktop).

IMAGES

  1. How to Configure Static IP Address on Ubuntu 20.04

    how to set static ip address in ubuntu 20 04

  2. How to Configure Static IP Address on Ubuntu 20.04

    how to set static ip address in ubuntu 20 04

  3. How to Set a Static IP Address in Ubuntu

    how to set static ip address in ubuntu 20 04

  4. How to Set Static IP in Ubuntu Server 20.04

    how to set static ip address in ubuntu 20 04

  5. How to Configure Static IP Address on Ubuntu 20.04

    how to set static ip address in ubuntu 20 04

  6. How to Configure Static IP Address on Ubuntu 20.04

    how to set static ip address in ubuntu 20 04

VIDEO

  1. How to Configure ip Programatically in c# and .net

  2. How to Set Static IP in Ubuntu Server 20.04. Change and configure ip adress using putty

  3. How To Configure Static IP in Ubuntu 18.04 Desktop

  4. How to set a static IP Ubuntu 22.04 LTS (3 ways)

  5. CARA KONFIGURASI IP ADDRESS LINUX UBUNTU SERVER 23.10 (MANTIC MINOTAUR) PADA VIRTUALBOX

  6. How to disable IPv6 in Ubuntu 20.04

COMMENTS

  1. How to Configure Static IP Address on Ubuntu 20.04

    How to Configure Static IP Address on Ubuntu 20.04 Posted Sep 15, 2020 • 5 min read This article explains how to set up a static IP address on Ubuntu 20.04. Typically, in most network configurations, the IP address is assigned dynamically by the router DHCP server.

  2. How to Configure Static IP Address on Ubuntu 20.04

    Network Configuration Ubuntu uses the NetworkManager daemon for managing network configuration. You can configure a static IP either graphically or on the command line. For this guide, we will focus on setting a static IP address using both the GUI and on the command line, and here is the IP configuration:

  3. How do I set a static IP in Ubuntu 20.04.3 LTS?

    One of the steps is setting up a static IP address. So, I was glad to find this answer. Following it, I created /etc/netplan/50-cloud-init.yaml file, pasted network: ethernets: enp0s3: addresses: [desired_ip_address/24] gateway4: my_router_ip_address dhcp4: no nameservers: addresses: [1.1.1.1,8.8.8.8] optional: true version: 2 and run

  4. How to Set a Static IP Address in Ubuntu

    Quick Links What Is a Static IP Address? Setting a Static IP in Ubuntu Set a Static IP in Ubuntu with the GUI Connection Convenience Key Takeaways After gathering your connection name, subnet mask, and default gateway, you can set a static IP address in the terminal using the nmcli command.

  5. How to Configure Static IP Address on Ubuntu 20.04

    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. Address: 192.168.1.100.

  6. How to Assign Static IP Address on Ubuntu 20.04 LTS

    It is always recommended to assign a static IP address to a Linux system because static ip address will be persistent across the reboots. Recently canonical has released its stable operating system " Ubuntu 20.04 LTS (Focal Fossa) " for both desktop and servers.

  7. How to configure static IP address on Ubuntu 20.04 Focal Fossa Desktop

    Click on Apply button. Restart your network by using the provided ON/OFF switch. Check your new static IP address configuration. Configure Static IP address on Server In this example we will set a static IP address on the Ubuntu 20.04 server to 192.168.1.202/24 with default gateway to 192.168.1.1 and DNS servers 8.8.8.8 8.8.4.4 192.168.1.1.

  8. How do I set a static IP in ubuntu server 20.04?

    2 Answers. You set it in /etc/netplan/ it's quite easy. I wrote about it here. You should include the steps here, and not just link to the article. gateway4 is long deprecated and steps are not here. Down. Static ip can be set in network settings in Ubuntu, see this.

  9. Configuring Ubuntu 20.04 to use a Static IP Address

    5. We are now in the right place to configure a static IP address for our Ubuntu 20.04 system. Before we can set the static IP address, we must change the DHCP mode from " automatic " to " manual " ( 1.) Switching DHCP to manual mode, we will be able to specify the address ( 2. ), netmask ( 3. ), and gateway ( 4. ).

  10. How to set a Static IP address on Ubuntu 20.04?

    So this post is about how to define a static IP address in Ubuntu 20.04. A Static IP address. An IP address is an identifier held by each device that connects to the Internet or a computer network. In the case of the Internet, it must be unique to avoid connection conflicts. On the one hand, there are dynamic IP addresses that change their ...

  11. Configure static IP address on Ubuntu 20.04

    · Jul 3, 2021 At some point you will need a static IP address on your Linux server or Virtual Machine. One of the main reason to do so is having a convenient remote access to your server or...

  12. Setting a Static IP in Ubuntu

    Here are the steps: Search for settings. Click on either Network or Wi-Fi tab, depending on the interface you would like to modify. To open the interface settings, click on the gear icon next to the interface name. Select "Manual" in the IPV4 tab and enter your static IP address, Netmask and Gateway.

  13. Linux Basics

    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. It covers network configuration for all current versions of Ubuntu and ...

  14. How to Configure Static IP Address on Ubuntu 20.04

    By RoseHosting October 10, 2021 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. Here's how to set a static IP address on your Ubuntu 20.04 install. Link to Article:

  15. How to set a static ip address in Ubuntu Server 20.04

    Even when you start an instance in the cloud, the network is configured with dynamic addressing using the DHCP server setup by the cloud service provider. In this chapter, you will learn how to configure the network interface with static IP assignment. Follow these steps to connect to the network with a static IP:

  16. How to Set Static IP on Ubuntu 20.04 Desktop?

    If you want to set a static IP Address on Ubuntu 20.04 LTS Desktop systems, then this tutorial helps you to set a static IP Address on Ubuntu 20.04 LTS Desktop systems. I checked with the following two methods: Set Static IP on Ubuntu 20.04

  17. How to Configure Static IP address on Ubuntu 20.04

    How to Configure Static IP address on Ubuntu 20.04. How to Configure Static IP address on Ubuntu 20.04.

  18. How to Configure Static IP Address on Ubuntu 20.04 LTS (#Ubuntu #Static

    In this step-by-step tutorial, learn How to Configure Static IP Address on Ubuntu 20.04 LTS.🚩 Connect with me on social- LinkedIn: https://www.linkedin.com/...

  19. Set Static IP address inside Ubuntu Server 20.04

    How to set Static IP address for Ubuntu Server 20.04 Check out full Virtualization with VirtualBox course: https://www.udemy.com/course/virtualization-with-v...

  20. How To Configure Static IP Address On Ubuntu 20.04 Server

    How To Configure Static IP Address On Ubuntu 20.04 ServerNow I want to share how to configure static ip address on ubuntu 20.04 server. 👉 https://technology...

  21. How to Configure Static IP Address on Ubuntu 18.04

    In the Activities screen, search for "network" and click on the Network icon. This will open the GNOME Network configuration settings. Click on the cog icon. In "IPV4" Method" section, select "Manual" and enter your static IP address, Netmask and Gateway. Once done, click on the "Apply" button.

  22. No Internet after static IP Ubuntu 22.04

    Improve this question. I have a Ubuntu 22.04 Server, and one to an other day i dosn't become from the router a dhcp adress, but when i set a static ip adress i can connect localy to the services on the server, but I can not get a connection to the internet. I have tried to set who I described above, to set a static IP (I did this in Netplan ...

  23. How to Set a Static IP Address in Ubuntu

    How to Configure Static IP Address in Ubuntu 20.04 How to Set Static IP Address on Ubuntu Server Using Netplan. Step 1: Open your terminal and head over to the /etc/netplan directory. You will find a YAML configuration file which you will use to configure the IP address.. Step 2: In our case the YAML file is 01-network-manager-all.yaml with the default settings as shown.

  24. Ubuntu 22.04 can't set correctly ipv6 address

    # The loopback network interface auto lo iface lo inet loopback auto be0 iface be0 inet static address 10..100.138 netmask 255.255.255.192 network 10..100.128 broadcast 10..100.191 gateway 10..100.129 post-up ip route flush cache post-down ip route flush cache post-up sleep 10s && ping -q -c 60 10..100.129 > /dev/null 2>&1 || true & iface ...

  25. How to Set Static IP on Ubuntu 20.04 (Desktop)

    Ubuntu 20.04 systems uses netplan from the previous LTS system. The desktop systems provides an attractive graphical user interface to work with it. Using the GUI, you can easily change or set a static IP address on your Ubuntu system. Set A Static IP on Ubuntu 20.04. You must have root or sudo privileged account account to the Ubuntu system.