LinuxOPsys

Configure Static IP Address on Ubuntu 20.04 (Server CLI and Desktop)

how to configure ip address ubuntu 20

In your IT environment, sometimes you may be compelled to configure a static IP instead of relying on the DHCP protocol. A perfect example is when you are setting up a Ubuntu server to act as a file or a web server for your organization. A static IP, as the name suggests, ensures that the IP address of your system remains unchanged. With DHCP, the IP address changes once the lease time for the IP address expires and this is undesirable for servers.

In this guide, we will explore two ways of manually assigning a static IP on Ubuntu 20.04. We will demonstrate how you can configure a static IP on an instance of Ubuntu server and Ubuntu desktop.

Assign a static IP on Ubuntu server 20.04

From Ubuntu 17.10 and later versions, networking is controlled by the Netplan feature. The configuration files for Netplan are located in the /etc/netplan directory and are written in YAML. Inside this directory, you will find YAML configuration files labeled either 50-cloud-init.yaml , or 00-installer-config.yaml .

However, If you are running a cloud instance of Ubuntu, chances are that it is managed by cloud-init which auto-assigns it an IP address by leveraging the DHCP protocol. Before we proceed further, you need to disable cloud-init. To achieve this, open the subiquity-disable-cloudinit-networking.cfg cloud-init configuration file in the /etc/cloud/cloud.cfg.d/ directory

Set the ' network ' directive to ' disabled '.

Save the changes and quit. Next, head over to the Netplan configuration file. In my case, I have the 00-installer-config.yaml file.

how to configure ip address ubuntu 20

From the configuration file, we can see the ' network' directive that has 2 elements. The first one is the ' ethernets ' which specifies the network interface and the second one is the version of the renderer which is ' systemd-networkd ' for non-GUI instances and NetworkManager for Ubuntu desktop ( With GUI )

Default Netplan configuration file

We are going to set the ' dhcp4 ' value to ' no ' to disable the DHCP protocol and specify the interface's Static IP as follows.

To assign a static IP address to  ens3  interface, modify the file as follows:

  • Specify the static IP address of the server. in the   addresses : section, specify an IPv4 address to be assigned to the network interface.
  • Next, Specify the gateway.
  • Under  nameservers , specify the DNS or IP addresses of the nameservers. Here, we have specified Google's DNS which is 8.8.8.8 and the Router's IP.

Set Static IP on Ubuntu 20.04

Save the YAML file and exit. To apply the changes made, run the command:

You can use the ifconfig or ip command to verify that your network interface is set to use the static IP configured moments ago.

Netplan apply

Additionally, you can use the IP route show command to display the new routes on your system.

Show IP routes on a Linux system

Perfect! We have successfully configured a static IP on the Ubuntu server. Let's now switch gears and see how you can replicate the same on Ubuntu Desktop 20.04

Configure Static IP on Ubuntu 20.04 Desktop

If you are running a Desktop GUI, then configuring a static IP should be quite easy. Click on the ' Network icon ' at the top right corner of your screen and select the 'Wired Settings ' option.

Select Wired settings option

This opens the 'Network ' configuration page. In the 'Wired ' section, click on the gear wheel icon.

Network settings page

This displays a summary of your current IP configuration. By default, the system obtains its IP configuration via the DHCP protocol. We will change from using DHCP to Manual.

Ubuntu Desktop IP configuration

So, click on the ' IPv4 ' tab which directs you to this section. As anticipated, DHCP is turned on.

IPv4 configuration on Ubuntu 20.04

Switch from ' Automatic (DHCP) ' to ' Manual '. Then specify the static IPv4 address including the netmask, gateway, and DNS servers. To save the changes, click on the ' Apply ' button.

Configure static IP Ubuntu 20.04

Head back to the ' Network' section and restart the networking service by toggling off and on.

Restart NetworkManager on Ubuntu 20.04

Once again, click on the gear wheel icon and confirm that the static IP settings have reflected.

Confirm static IP settings

And it's as simple as that. We have successfully configured a static IP on Ubuntu Desktop.

Ubuntu, like most other systems, comes configured with DHCP to obtain an IP from the DHCP server, or router. In this guide, we have covered how you can apply static IP settings on command-line and using the GUI. Before setting a static IP, it's always recommended to reserve the IP that you want to assign to your server on the router. Equally important is to ensure that no other client system is using that IP address to avoid an IP conflict.

If this resource helped you, let us know your care by a Thanks Tweet. Tweet a thanks

Like

Sorry about that.

About The Author

James kiarie.

James Kiarie

James Kiarie is a skilled and certified LPIC Linux administrator with a strong passion for technical writing, specializing in the Linux domain. With over four years of experience, he has crafted numerous technical guides, helping a wide audience navigate through various Linux distributions.

Nmap to Scan Open Ports – Examples + Screenshots

How to List Network Interfaces in Linux

How to Get IP address in Linux

How to Permanently add Static Route in Linux

Ping IPv6 Address from Windows and Linux CLI

How to Check Ports in Use in Linux (Listening Ports)

Tshark Examples with Cheat Sheet

How to Learn Linux – A Master Guide

13 Modern Alternatives to Linux Commands

Basic Linux Commands You Should Know

14 Command Line Tools to Check CPU Usage in Linux

13 Cool Things to Do with Linux

Leave a Reply

Leave a comment cancel reply.

Tecmint: Linux Howtos, Tutorials & Guides

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

Configure Network Ethernet Connection Using nmcli Tool

How to Configure Network IP Connections Using ‘nmcli’ in Linux

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

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.

Thanks for documenting this. However, after a reboot, I am left with the old IP address (DHCP). Guess there is another process that overrules the yaml file, but what??

Hey Pieter, that’s awkward. Ideally, the IP should not change since it’s a static IP. Did you try out both procedures. I’m just curious.

I had a static IP in the yaml file and this does not get an update if you adjust its IP via.

netplan ip a prior to gui adjustments gui DHCP => ip DHCP Gui static ip b => ip a It seems that netplan is not updated via GUI adjustments Enjoy the coffee ‘)

Could this lead to a clash of IP addresses between two computers on the same network? Another computer (computer B) which gets its IP address dynamically comes online when the computer with the static IP (computer A) is offline.

The dhcp server could assign the IP to computer B. Subsequently, when computer A comes online and tries to join the network there would be an IP conflict and both computers could end up not being able to connect to network resources or perform other network operations.

In some routers, this can be managed by restricting the range of IP addresses that the router can dynamically assign. Many routers don’t have that option.

To avoid the potential of such conflicts, I assign static IP addresses on the dhcp server to computers on the network based on the MAC addresses of their NICs.

I would appreciate your thoughts on how to prevent IP conflicts when the network is made of some devices that have static in and others have dynamic IP addresses assigned to them. This scenario is more common today where network devices like smart phones, tablets, smart TVs, and media streaming devices connecting to the network.

Managing IP addresses by MAC addresses is a pain and it would be very helpful if there is an easier way to prevent IP conflicts.

Your concern is very valid. To avoid a conflict in IP address assignment in a network, as you have just described, consider reserving the IP assigned to the server on the router. Say for example, if you want to assign Server A an IP of 172.16.0.100, simply login into your router and reserve the IP address. This prevents the IP from being made available to client PCs & other network devices via the DHCP protocol.

Ideally, before the static assignment, proper mapping of your network is advised so as to know which device is using which IP address. You can use nifty tools like Nmap to scan your network to get to know which IP addresses are in use to avoid assigning a duplicate IP statically on the server.

I hope this answers your question.

Wonderful post. Very simple and to the point. Thank you!!!! Keep it up!!!

Thank you very much Jaidev Shah. Keep it Tecmint.

Hi, why when we use the desktop method, the interfaces file does not get updated ? Where does the desktop tool write the information ?

That’s actually a very interesting question and I did not think about it before. I just configured a static IP on one of my Ubuntu boxes and used grep from /etc/ folder recursively to search for that IP. The IP address was written in:

/etc/NetworkManager/system-connections/Wired\ connection\ 1

So if you need to look where the desktop tool has written your settings, you can look at:

/etc/NetworkManager/system-connections/

Hey Marin, thanks for your contribution. I hadn’t actually seen it from that angle. Quite interesting I must say.

Great article just wondering about this part: “Remember to replace “enp0s3” with the name of your network adapter??? what do u mean by this? do you mean we should not change this name enp0s3 or changed with our network adapter? Cheers

Means, you should change “enp0s3” with your network adapter name for example, eth0 or eth1..

Sorry for my english, I would put a secondary IP in the same interface, like old versions (eth0 192.168.1.100… eth0:1 10.10.0.100) I know how to do it in the old versions, but in version 15.10, they have changed the commands. Can you help me?

Hello Nikon,

As the answer of this question is too long for the comment section, I would recommend you to submit your question to our Linuxsay discussion forum, where we will gladly provide more details:

http://linuxsay.com/

Where do the Nameserver numbers obtained? Elaborate on “Make sure to use your own settings depending on the network to which you are connected to.”

Can you please expand on this? IMPORTANT NOTE: For the purpose of this tutorial, I will be using the following settings:

IP Address: 192.168.0.100 Netmask: 255.255.255.0 Gateway: 192.168.0.1 Nameserver: 8.8.8.8 Nameserver: 8.8.4.4 Make sure to use your own settings depending on the network to which you are connected to. Where do you obtain the Nameserver numbers?

This depends on few things:

If your machine is connected to a router, you should see the settings in there.

If you are plugging your ISP’s internet cable directly to your computer (i.e no router, modem etc), you should use your ISP’s settings.

I want 1st IP by DHCP and 2nd static but, in Ubuntu 15.10 mi interface isn’t eth0 it is eno1 and if I put eno1:1 don’t works.

Actually the init script does exactly that – it calls systemctl. You can see it in the screenshot:

“restarting networking (via systemctl): networking service”

Both scripts do the same.

Why not use systemd to restart networking directly?

`systemctl restart network`

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.

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 .

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 connection command with the show argument.

nmcli connection show

Using nmcli to list network connections

This displays some information about each connection. We only have a single connection configured.

The details of a single network connection displayed by nmcli

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.

The output of the ip addr command showing the ip address of the computer

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

Using ping to determine if an IP address is in 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 responds to the ping requests, so 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."

Using the ip command to find the IP address of the default gateway

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

Creating a new connection with the nmcli command

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"

Using the nmcli command to set the DNS servers for a connection

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

Using the nmcli command to set an IP address to static

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

nmcli con up "static-ip" ifname enp0s3

Using the nmcli command to start a network connection

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

nmcli con show

The details of two network connections displayed by nmcli

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.

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.

The system menu with the

To create a new connection using the "Settings" application, click the " + " icon on the "Networks" page, above the list of wired connections.

The wired connection section in the Network tab of the Settings app

A dialog appears. We need to provide a name for our new static IP connection.

Giving a name to a new connection profile in the

We're calling our new connection "static-2." Click the "IPv4" tab.

Supplying the IPv4 connection details to a new connection profile in the

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.

A newly-added connection in the wired connection section of the Network tab of the Settings app

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.

The wired connection section in the Network tab of the Settings app

A dialog box opens. Click on the "IPv4" tab.

The IPv4 tab of the connection settings dialog

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.

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.

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.

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 20.04.3 LTS?

I'm trying to set up a lab computer as a ssh server following this guide . 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

where my_ethernet_num == enp9s0 . Buuuut, after this ip a showed no ip address for the Ethernet:

and sudo lshw -C network yielded *-network DISABLED . Then I tried to use that guide (section 'Static IP Address Assignment'). I created /etc/netplan/99_config.yaml , pasted the necessary code, run sudo netplan apply . Nothing changed except that I STOPPED SEEING wired connections in network settings... I tried the answer from here , and the 'Wired' section returned. But I can't change anything (for example, I can't pick 'Manual' option).

Screenshot

So, the questions are: how can I return the ability of changing it (in order to follow one more guide ), or is there any other solution that will succeed in setting static ip address?...

--EDIT from 12/05/2021--

Here are all of my .yaml files showed by ls -al /etc/netplan :

01-network-manager-all.yaml:

50-cloud-init.yaml:

99_config.yaml:

  • network-manager

Serg's user avatar

  • 1 Probably you should delete/revert all changes that you have made, to get back to the original configuration. Then just use "Manual" option from the GUI. No need to mess with configuration files manually. –  raj Nov 29, 2021 at 12:44
  • @raj, thank you for your comment! If I only knew how to revert all the changes... By the way, after rebooting, I suddenly found out that I can make changes to the settings! So, I'll try the the GUI option and write about results :) –  TopCoder2000 Nov 29, 2021 at 13:31
  • Why does your .yaml use enp0s3, when your interface is enp9s0? Are you using a Server or Desktop installation? –  heynnema Nov 29, 2021 at 23:37
  • @heynnema, because it was in the answer for 'How do I set a static IP in Ubuntu?' . As we can see, enp0s25 is used in the question, but then enp0s3 is used in the answer, so I thought that it always must be enp0s25. > Are you using a Server or Desktop installation? I would like to use a Desktop installation, but I don't know concretely which one I was using... Is there any difference? I tried to follow Desktop installation but I could get confused. –  TopCoder2000 Dec 1, 2021 at 19:31
  • @TopCoder2000 Your network can't possibly be working with enp0s3 in the .yaml file. It needs to be enp9s0. But if you're using a Desktop installation, then your .yaml is all wrong anyway. A Desktop installation has a GUI, a Server installation is CLI only. Also, your self-accepted answer doesn't really make a lot of sense. –  heynnema Dec 1, 2021 at 19:37

Pick ONE of the following two configurations...

Server installation with static IP...

Delete /etc/netplan/01-network-manager-all.yaml

Delete /etc/netplan/50-cloud-init.yaml

Edit /etc/netplan/99_config.yaml to look EXACTLY like this...

Note : regarding 192.168.0.116, make sure this address is outside of the DHCP range set in your router, and is not already used elsewhere.

Note : For DNS nameservers, settle on servers from one source... Google, Cloudflare, OpenDNS, etc. (3 max).

sudo netplan generate

sudo netplan apply

Desktop installation with static IP...

Delete /etc/netplan/99_config.yaml

Edit /etc/netplan/01-network-manager-all.yaml to look EXACTLY like this...

Note : Use the NetworkManager GUI to setup your static IP for "Wired Connection".

Note : See https://netplan.io/examples/ for examples and design info about netplan.

heynnema's user avatar

  • Thank you for your answer and netplan examples! Now ip a shows correct output. But how do I setup a static IP with NetworkManager GUI? –  TopCoder2000 Dec 6, 2021 at 18:28
  • @TopCoder2000 Firstly, you can't use both parts of my answer at the same time. It's part 1 or part 2. If you're using part 2, then my answer says "Use the NetworkManager GUI to setup your static IP for "Wired Connection"" . See the IPv4 tab. Click on the manual button. Fill in the address, mask, gateway, and DNS servers, and turn off DNS Auto. –  heynnema Dec 6, 2021 at 18:44
  • yes, I remember! I'll accept it as soon as I don't have any questions :) Yes, I'm using the second option. But you also wrote yesterday that 'Static IPs should be set to be outside of the DHCP range set in the router'. But how do I know that set? For example, the second answer from here says that we have to check DHCP server configuration... –  TopCoder2000 Dec 7, 2021 at 6:51
  • @TopCoder2000 You must log into the admin page of your router and find the DHCP server settings. For your computer's static IP, you'll need to pick an address outside of the DHCP server's range of addresses. –  heynnema Dec 7, 2021 at 15:01
  • Ah, good! Thanks! –  TopCoder2000 Dec 9, 2021 at 7:07

You must log in to answer this question.

Not the answer you're looking for browse other questions tagged networking 20.04 network-manager ethernet ..

  • The Overflow Blog
  • Who owns this tool? You need a software component catalog
  • Featured on Meta
  • Upcoming privacy updates: removal of the Activity data section and Google...
  • Changing how community leadership works on Stack Exchange: a proposal and...
  • Notifying users about the policy on AU concerning AI-generated content
  • AI-generated content is not permitted on Ask Ubuntu

Hot Network Questions

  • Contacted by COI PC
  • How can I properly make a bash prompt with error colors and emoji?
  • Store environment's body in LUA string
  • Would it be legal for a US state or the federal government to ban all homeopathic "medications"?
  • valve stem caps on tubeless tires
  • Which Potentials lead to Kepler's second Law?
  • What's wrong with my furnace blower wiring (only works on AUTO)?
  • Saturation region of BJT
  • How do airlines make money or get some other kind of advantage when I book a flight using miles not earned from flying?
  • In Indiana, can an apartment complex force you to remove social media posts if it retains to how they manage?
  • Does Android OS impose an SMS sending limit?
  • Space shuttle HUD - flight director vs velocity vector
  • Could Israel's PM Netanyahu be served with an arrest warrant from the ICC for war crimes, like Putin was because of Ukraine?
  • Why is Europe (Germany in particular) apparently paying so little for US troop presence/protection, compared to South Korea?
  • How can I remove the exterior face in PlanarFaceList?
  • Do you say "give a sociable compliment" when you mean you give a compliment as a way to socialize with people but it's not a true praise?
  • Is there a no-go theorem for or an upper bound on code threshold?
  • How to efficiently transport troops from orbit
  • Does paying a holder of public office to resign constitute bribery?
  • How do I read the last lines of a huge log file?
  • Can Survival Models model the time at which a random variable will first pass a certain point?
  • How do you say "on" as in "The book is on the table."?
  • Subdivision not working as intended, edges not generating
  • Old romantic horror movie about a guy that fell in love with a girl and later found out she's a ghost

how to configure ip address ubuntu 20

The Linux Centre

  • Network / Networking Commands / Ubuntu

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.

How to Configure Static IP Address on Ubuntu 20.04

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.

How to Configure Static IP Address on Ubuntu 20.04

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 .

How to Configure Static IP Address on Ubuntu 20.04

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.

How to Configure Static IP Address on Ubuntu 20.04

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

How to Configure Static IP Address on Ubuntu 20.04

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.

How to Configure Static IP Address on Ubuntu 20.04

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.

How to Configure Static IP Address on Ubuntu 20.04

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

How to Configure Static IP Address on Ubuntu 20.04

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

How to Configure Static IP Address on Ubuntu 20.04

To confirm the DNS servers, run the command:

How to Configure Static IP Address on Ubuntu 20.04

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.

How to Configure Static IP Address on Ubuntu 20.04

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

How to Configure Static IP Address on Ubuntu 20.04

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.

How to Configure Static IP Address on Ubuntu 20.04

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.

Tags: Networking Tips Ubuntu Tips

You may also like...

how to configure ip address ubuntu 20

Setting Up LAMP (Linux, Apache, MySQL/MariaDB, PHP and PhpMyAdmin) in Ubuntu Server 14.10

how to configure ip address ubuntu 20

How to Install and Configure an NFS Server on Ubuntu 18.04

how to configure ip address ubuntu 20

How to Configure Network Bonding or Teaming in Ubuntu

how to configure ip address ubuntu 20

How to Install Nginx, MySQL/MariaDB and PHP on RHEL 8

how to configure ip address ubuntu 20

How to Integrate ONLYOFFICE Docs with Jitsi on Ubuntu

how to configure ip address ubuntu 20

How to Use Two-Factor Authentication with Ubuntu

how to configure ip address ubuntu 20

The Ultimate Guide to Handling Filenames with Special Characters in Linux

how to configure ip address ubuntu 20

How to Use Git Version Control System in Linux [Comprehensive Guide]

how to configure ip address ubuntu 20

How to Install Apache, MySQL/MariaDB and PHP on RHEL 8

how to configure ip address ubuntu 20

How to Open, Extract and Create RAR Files in Linux

how to configure ip address ubuntu 20

How to Install Cacti with Cacti-Spine in Debian and Ubuntu

how to configure ip address ubuntu 20

Adminer – A Full-Featured MySQL Database Management Tool

how to configure ip address ubuntu 20

RHEV Clustering and RHEL Hypervisors Installation – Part 5

how to configure ip address ubuntu 20

How to Configure Networking in Ubuntu 20.04 with NetPlan

In this tutorial, you will learn how to configure networking in Ubuntu 20.04 with Netplan. You will learn how to set static IP addresses, DHCP addresses, as well as how to configure DNS and Wifi.

Introduced back in 18.04, April 2018, networking was redone using a new system called Netplan – a YAML based configuration network configuration system for NetworkManager and SystemD.

NetPlan Files

Network interfaces in Ubuntu 20.04 are configured in NetPlan YAML files, which are stored under /etc/netplan . The default file networking interfaces for a new Ubuntu 20.04 install is /etc/netplan/00-installer-config.yaml .

To edit the default netplan file, use the following command.

Alternatively, a simpler text editor by the name of nano can be used instead of vim.

How to Set Static IP Address

The following is an example Netplan file with a network interface that has a static IP address. The interface’s name is en01 and it has been assigned static IP addresses 192.168.1.25/24 for IPv4, and 2001:1::1/64 for IPv6.

As both IPv4 and IPv6 have been assigned static IP addresses, each has a gateway set too.

DNS Name servers are also defined in this file. We’ll cover DNS a little further down in this tutorial.

To apply changes to netplan you will need to reload your Netplan network configurations.

How to set DHCP Addresses

Dynamically addressed can be assigned for IPv4 and IPv6, provided your network has a DHCP server.

The following example shows how to enable DHCP for both IPv4 and IPv6. To enabled just one, you would remove the network IP version not needed.

To update your netplan configurations, run the netplan apply command.

How to Set DNS

The following is an example of a network interface id0 with nameservers configured.

  • search is a list of search domains, which are used when a non-fully qualified hostname is given. For example, if you were to ping server1 rather than server1.lab .
  • addresses is a list of IPv4 or IPv6 ip addresses for the DNS name servers. IPv6 must be quoted.

How to set WiFi Authentication

While WiFi is not something you would commonly configure Ubuntu server for, it it is prevalent enough you may consider using it in some use cases. To the following with walk you through configuring WPA and EAP wifi modes.

Systemd does not have native wifi support. In order for your network device to work with wifi you will need wpasupplicant installed.

Configuring WPA and EAP WiFi Connections

The most common home wifi configurations use mode WPA or EAP, while EAP is more common in enterprise. These two modes use a basic form of authentication using a password or shared-key.

For home users, the WPA mode is the simplest to use with a compatible wifi device. Devices that support WPA can automatically join wifi networks by pressing the WPA button on a compatible wifi router.

To configure WPA or EAP on Ubuntu using Netplan, you would add the auth scalar to your netplan configuration file. In the example below, we’ve added it to a ethernet interface named id0 .

The access-points scalar sets how the wifi connection will be established.

  • mode set the mode type for your wifi network interface. For connecting to access points the value should be set to infrastructure, which is the default.
  • bassid is the name of your wifi connection, as configured on your access point.
  • band is used to set the wireless band. It accepts two values: 5GHz and 2.4GHz. If left unset, the wifi endpoint and your network device will automatically establish the best band. By setting this value you will force the connection to use a specific band.
  • channel is used to set your wifi channel, and only takes affect if the band property is set.

WPA and EAP connection modes accept the following configurations.

  • none to disable key management
  • psk for WPA with pre-shared key, common for home wifi.
  • eap for WPA with EAP, which is common for enterprise wifi networks.
  • password sets the pre-shared key or password for your wifi network, when the mode is set to either psk or eap .

No related posts found

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.

 Yes, add me to your new blog post notifications list

Setting a Static IP in Ubuntu – Linux IP Address Tutorial

In most network configurations, the router DHCP server assigns the IP address dynamically by default. If you want to ensure that your system IP stays the same every time, you can force it to use a static IP.

That's what we will learn in this article. We will explore two ways to set a static IP in Ubuntu.

Static IP addresses find their use in the following situations:

  • Configuring port forwarding.
  • Configuring your system as a server such as an FTP server, web server, or a media server.

Pre-requisites:

To follow this tutorial you will need the following:

  • Ubuntu installation, preferably with a GUI.
  • sudo rights as we will be modifying system configuration files.

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

We will need our current network details such as the current assigned IP, subnet mask, and the network adapter name so that we can apply the necessary changes in the configurations.

Use the command below to find details of the available adapters and the respective IP information.

The output will look something like this:

image-14

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

TecAdmin

How to Configure Static IPv4 Address on Ubuntu 20.04

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 provide 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 a root or sudo privileged account in the Ubuntu system. Login to your Ubuntu 20.04 Desktop system. After that open settings on your machine as shown in the below screenshot.

Open Settings Ubuntu 20.04

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

Open network connections 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.

Set Static IP Ubuntu 20.04

View Current IPs on Ubuntu

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

View IP Ubuntu 20.04

To view IP on the 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.

Multiple static IP on Ubuntu 20.04

Related Posts

Apt configuration file options /etc/apt/apt.conf.

How to Setup DKIM (DomainKeys) with Postfix

A Step-by-Step Guide to Installing OpenDKIM with Postfix on Ubuntu – Unleash the Power of DKIM!

How to Install Composer on Ubuntu 22.04

How to Install and Use Composer on Ubuntu 22.04

Leave a reply cancel reply.

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

Type above and press Enter to search. Press Esc to cancel.

Logo

How to Configure Static IP Address on Ubuntu 20.04 - DesignLinux

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.

Bash Select (Make Menus)

Sysmon – a graphical system activity monitor for linux.

It's FOSS

How to Assign Static IP Address on Ubuntu Linux

Dimitrios

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

Static IP set up Ubuntu

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.

Assign Static IP address in Ubuntu Linux

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.

Assigning static IP in Ubuntu Linux

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.

Dimitrios is an MSc Mechanical Engineer but a Linux enthusiast in heart. His machines are powered by Arch Linux but curiosity drives him to constantly test other distros. Challenge is part of his per

Meet DebianDog - Puppy sized Debian Linux

Reduce computer eye strain with this nifty tool in linux, install open source dj software mixxx version 2.0 in ubuntu, install adobe lightroom alternative rawtherapee in ubuntu linux, complete guide to installing linux on chromebook, 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

It's FOSS

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.

UbuntuMint – Everything About Ubuntu Linux

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.

Netplan Configuration Files

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.

Check Network Interface Name

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.

Configure IP Address in Ubuntu

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.

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

Check IP Address in Ubuntu

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.

How to Batch Convert PNG Images to JPG Format in Linux

How to Add a New Device to BTRFS File System in Linux

Photo of author

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

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.

ubuntu logo

How to configure a static IP address on Ubuntu 20.04

Table of Contents

How to configure a static IP address on Ubuntu 20.04:

It is a good idea to set a static or fixed ip address to a server so that you can guarantee that the machine will always have the same ip address to make it easier to connect to. I prefer to set a static ip dynamically using my dhcp server but if you prefer to add a static IP address then this can easily be done using the following process:

Set a static IP address:

Find the correct interface name:.

Open a terminal and run the following command:

How to configure a static IP address on Ubuntu 20.04

In the example above the network card is eth0 as it is the only interface with an ip address.

Backup the networking file

It is a good idea to back up the networking file before you make any changes so that it can be quickly reverted if things go wrong. Run the following command to make a backup copy of the file:

This will create a file called 00-installer-config.yaml.bak in the /etc/netplan/ folder in case you need it.

Edit the 00-installer-config.yaml file to set the static IP Address

Edit the 00-installer-config.yaml file in your desired editor

Initial Ubuntu Server 20.04 setup on a freshly installed Ubuntu 20.04 server

If your server is set to dhcp then you will see something like:

Initial Ubuntu Server 20.04 setup on a freshly installed Ubuntu 20.04 server

Edit the file to look something like:

Save the file.

Initial Ubuntu Server 20.04 setup on a freshly installed Ubuntu 20.04 server

Apply the changes:

Initial Ubuntu Server 20.04 setup on a freshly installed Ubuntu 20.04 server

The server will then be using the new address. If you were connected via ssh you will have to open a new session and connect to the NEW IP ADDRESS:

Initial Ubuntu Server 20.04 setup on a freshly installed Ubuntu 20.04 server

The server will now use this address every time it is rebooted from now on.

To revert the changes you just need to do the following:

Over write the edited file with the backup file:

Initial Ubuntu Server 20.04 setup on a freshly installed Ubuntu 20.04 server

Reload netplan:

Initial Ubuntu Server 20.04 setup on a freshly installed Ubuntu 20.04 server

The server will now be configured for dhcp and should have its old ip address again:

Initial Ubuntu Server 20.04 setup on a freshly installed Ubuntu 20.04 server

The server is now ready to install what ever software that you would like to install. For some ideas of what to install go to our  Ubuntu Section  of the site.

Leave a Comment Cancel Reply

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

Privacy Overview

XDA Developers

How to set a static internal IP in Ubuntu

Quick links, how to set static internal ip in ubuntu using the gui, how to set static internal ip in ubuntu using the terminal and text editor.

There comes a time when you might have to configure Ubuntu or any other Linux distribution with a static IP address. While you can't change your external static IP address, since it's the one your internet service provider provides, you can change your internal one. This is the IP address used on your network inside your home or office.

Though many tasks on Ubuntu usually require you to visit the terminal app and deal with lines of text, changing your internal IP is easy. You can do this through the settings app and the Graphical User Interface (GUI). Of course, if you want, you can also swap things out by going through the terminal. Here's how.

Without any technical know-how or knowledge, you can set a static IP in Ubuntu through the settings app. Just note, you will have to use the terminal once to find a range of IP addresses that you can assign. Once you do that, you just tap the Windows Key or the Superkey on your device and search for Settings . Once the app is open, proceed with the steps below.

  • If you're connected to the internet via Wi-Fi, choose Wi-Fi . If you're connected via Ethernet, select Network.
  • Once the interface is open, click the settings icon next to the network you're connected to.
  • From the list of tabs at the top, choose IPv4.
  • Under ipv4 method, be sure to choose Manual.
  • Under Addresses, enter the IP address, the Netmask, and the Gateway you want to use. For finding IP addresses that'll work on your network, you can proceed with the steps below.
  • Open a terminal session. With Ctrl, Alt, and T. Install net-tools with the command sudo apt install net-tools.
  • In this case, we have an inet of 192.168.1.176 and a netmask of 255.255.255.0. We can enter those numbers and can calculate the usable range using this website .
  • When you've calculated the usable range of addresses, choose a valid IP address that falls within this range. Then, you can click Apply at the top.

Any changes you apply will automatically go into effect. If you want, you can also use the terminal to confirm your IP address. Launch it with Ctrl, Alt, and T on your keyboard. Once launched, enter the command ip addr or ip a . You should see an interface IP address listed.

If you're a bit more technical and want to set a static IP in Ubuntu using the terminal, that is possible. You'll have to edit some lines of text and go through a few extra steps, but here's how:

  • Display information about your network. Use the command nmcli connection show. You'll see a network name, a UUID, a Type, and a Device. If this package isn't installed (though it should be, as it comes preinstalled with Ubuntu), then run sudo apt-get install network-manager
  • Note down the range of IP addresses you'll be able to use. Use the command ip addr to find out your machine's current IP address. This tutorial assumes that your network adapter is called enp0s3. If it isn't, then look for the correct one and also change the interface names in the subsequent commands. In the above example, we have an inet of 10.0.2.15, with the /24 denoting that the network uses a 255.255.255.0 subnet mask. In most cases, your usable network range will be whatever is in the first three places of the internal IP address, and then any unused number on your network between 1 and 255 in the last section. For example, we can use 10.0.2.16. If you're unsure, you can enter the subnet mask and your internal IP address into this website to calculate the usable range.
  • Note the IP address of your default gateway with the command ip r. In our example, it's 10.2.2.2.
  • Next, we'll add a new static connection option. Run the following command, making sure to change the numbers after "ip4" and "gw4" depending on your network conditions. These are the IP address you want to change your machine to and the current default gateway, respectively. sudo nmcli con add con-name "static" ifname enp0s3 type ethernet ip4 10.0.2.13/24 gw4 10.0.2.2 In our case, we do the following.
  • Set your DNS, manual DHCP (so, a static IP), and enable the connection. You can do that by running the following commands in succession. nmcli con mod "static" ipv4.dns "1.1.1.1,8.8.8.8" You can swap out the DNS servers above for whatever you want, they are in order of primary and secondary. nmcli con mod "static" ipv4.method manual; nmcli con up "static" ifname enp0s3 Once done, you can run nmcli con show to see if the new connection is enabled. If the output above looks like yours, then you're ready to go!

Setting complete

That's all you need to set up a static IP in Ubuntu. It doesn't take much effort. Remember, we're always writing about Linux, so you can check out our guide to the best Linux laptops should you need one.

How to set a static internal IP in Ubuntu

5 Commands to Get IP Address Information on Linux

If you are using a Linux distro without a graphical interface then to find the IP address you have to use the command line interface. Here in this article, we learn the multiple commands that can be used to get information about networking configuration. Finding IP address details can be beneficial in networking configuration and troubleshooting purposes.

Few popular commands to obtain IP Address information on Linux servers or desktops.

The most common command to display network adapter information is “IP addr” on the Linux system. When we execute it without supplying any extra arguments, the command will show the IP address, netmask, gateway, physical address of the adapter, and other details…

To use it, run the given command in your Terminal:

ip addr command

2. ifconfig

Although “ifconfig” is a common command and traditional utility, many modern Linux distros would not have it by default and users need to install it manually. Like “ ip addr” this one can also be used to display IP address information for all active network interfaces.

ifconfig command

3. hostname -I

Those who don’t want detailed info about their Linux system network interfaces, instead of only the IP addresses assigned to them on the system, can use the hostname command with the “ -I ” option. This command provides a simple list of IP addresses assigned to all network interfaces on the system.

hostname command to get IP address

Linux systems users with GUI can also use the Network Manager’s “nmcli” command which offers a powerful interface for managing network connections. Unlike other commands, “ nmcli ” gives well-detailed and structured information about the network interfaces of the system including their IP addresses, here is the command to follow, you can use it without any parameter as well.

nmcli device show command

Note : Those who don’t have “ Network Manager ” and if you like its way of showing the details, install it manually. For example in Ubuntu or Debian, use the command – “ sudo apt install network-manager ” to install it.

nmcli command

5. ip route

The last command that we discuss in this article is “ ip route ” used to display the kernel’s IP routing table . It shows the routes the system learns, including the destination network, gateway, and interface used for forwarding packets.

Although, the output of the “ IP route” command will also have the private address of the PC as well, however, if you want to list only it rather than routing details use the command in the following way:

ip route command to find ipaddress

So, we have seen how we can use the commands like “ ip addr “, “ ifconfig “, “ hostname “, “ nmcli “, and “ ip route “, to quickly find the details of our network interfaces on Linux-running devices. Also, it is better to run these commands with Admin rights i.e. using ‘sudo’ to access restricted network information and make configuration changes when necessary.

Other Articles:

How to find the IP address of a Guest in VirtualBox?

  • Use GUI to find my IP address on Ubuntu 22.04 Jammy JellyFish
  • Assign multiple IP addresses to Ubuntu on a single network interface- GUI
  • How to install ifconfig on Kali Linux to check IP address

Newly installed Bitnami Ghost blog keeps redirecting to the LocalHost

Newly installed Bitnami Ghost blog keeps redirecting to the LocalHost

Use Cockpit as Virt-Manager alternative to manage KVM VMs

Use Cockpit as Virt-Manager alternative to manage KVM VMs

How to install KVM on Oracle Linux 9?

How to install KVM on Oracle Linux 9?

How to Install Cockpit-Podman for Container Management on Linux

How to Install Cockpit-Podman for Container Management on Linux

What is the difference between OpenVZ and Docker?

What is the difference between OpenVZ and Docker?

Leave a Comment Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed .

Press ESC to close

How to Configure Static IP Address on Ubuntu 20.04 Configure Static

How to Configure Static IP Address on Ubuntu 20.04

How to Configure Static IP Address on Ubuntu 20.04 Configure Static

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. Setting a static IP address may be required in different situations, such as configuring port forwarding or running a media server .

Configuring Static IP address using DHCP #

The easiest and recommended way to assign a static IP address to a device on your LAN is to configure a Static DHCP on your router. Static DHCP or DHCP reservation is a feature found on most routers which makes the DHCP server to automatically assign the same IP address to a specific network device, each time the device requests an address from the DHCP server. This works by assigning a static IP to the device’s unique MAC address.

The steps for configuring a DHCP reservation vary from router to router. Consult the vendor’s documentation for more information.

Ubuntu 17.10 and later uses Netplan as the default network management tool. The previous Ubuntu versions were using ifconfig and its configuration file /etc/network/interfaces to configure the network.

Netplan configuration files are written in YAML syntax with a .yaml file extension. To configure a network interface with Netplan, you need to create a YAML description for the interface, and Netplan will generate the required configuration files for the chosen renderer tool.

Netplan supports two renderers, NetworkManager and Systemd-networkd. NetworkManager is mostly used on Desktop machines, while the Systemd-networkd is used on servers without a GUI.

Configuring Static IP address on Ubuntu Server #

On Ubuntu 20.04, the system identifies network interfaces using ‘predictable network interface names’.

The first step toward setting up a static IP address is identifying the name of the ethernet interface you want to configure. To do so, use the ip link command, as shown below:

The command prints a list of all the available network interfaces. In this example, the name of the interface is ens3 :

Netplan configuration files are stored in the /etc/netplan directory. You’ll probably find one or more YAML files in this directory. The name of the file may differ from setup to setup. Usually, the file is named either 01-netcfg.yaml , 50-cloud-init.yaml , or NN_interfaceName.yaml , but in your system it may be different.

If your Ubuntu cloud instance is provisioned with cloud-init, you’ll need to disable it. To do so create the following file:

/etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

To assign a static IP address on the network interface, open the YAML configuration file with your text editor :

/etc/netplan/01-netcfg.yaml

Before changing the configuration, let’s explain the code in a short.

Each Netplan Yaml file starts with the network key that has at least two required elements. The first required element is the version of the network configuration format, and the second one is the device type. The device type can be ethernets , bonds , bridges , or vlans .

The configuration above also has a line that shows the renderer type. Out of the box, if you installed Ubuntu in server mode, the renderer is configured to use networkd as the back end.

Under the device’s type ( ethernets ), you can specify one or more network interfaces. In this example, we have only one interface ens3 that is configured to obtain IP addressing from a DHCP server dhcp4: yes .

To assign a static IP address to ens3 interface, edit the file as follows:

  • Set DHCP to dhcp4: no .
  • Specify the static IP address. Under addresses: you can add one or more IPv4 or IPv6 IP addresses that will be assigned to the network interface.
  • Specify the gateway.
  • Under nameservers , set the IP addresses of the nameservers.

When editing Yaml files, make sure you follow the YAML code indent standards. If the syntax is not correct, the changes will not be applied.

Once done, save the file and apply the changes by running the following command:

Verify the changes by typing:

That’s it! You have assigned a static IP to your Ubuntu server.

Configuring Static IP address on Ubuntu Desktop #

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. To open the interface settings, click on the cog icon next to the interface name.

In “IPV4” Method” tab, select “Manual” and enter your static IP address, Netmask and Gateway. Once done, click on the “Apply” button.

How to Configure Static IP Address on Ubuntu 20.04 Configure Static

To verify the changes, open your terminal either by using the Ctrl Alt T keyboard shortcut or by clicking on the terminal icon and run:

The output will show the interface IP address:

Conclusion #

We’ve shown you how to configure a static IP address on Ubuntu 20.04.

If you have any questions, please leave a comment below.

Share Article:

You might also like.

Comment on How To Configure Auto-Login for Windows 7 by David Comment Configure

Comment on How To Configure Auto-Login for Windows 7 by David

How to Install and Configure VNC on Ubuntu 20.04 Configure Install

How to Install and Configure VNC on Ubuntu 20.04

Install and Configure Fail2ban on Debian 10 Configure Install

Install and Configure Fail2ban on Debian 10

Other stories, how to run telnet / tcpdump in openshift v4 coreos nodes, configure aws vpc flow logs to cloudwatch log group.

IMAGES

  1. How to Configure Static IP Address on Ubuntu 20.04

    how to configure ip address ubuntu 20

  2. How To Configure Static IP Address On Ubuntu 20.04 Server » TechnologyRSS

    how to configure ip address ubuntu 20

  3. How to Configure Static IP Address on Ubuntu 20.04

    how to configure ip address ubuntu 20

  4. How to Configure Static IP Address on Ubuntu 20.04?

    how to configure ip address ubuntu 20

  5. How to Configure Static IP Address on Ubuntu 20.04

    how to configure ip address ubuntu 20

  6. How to Configure Static IP Address on Ubuntu 20.04

    how to configure ip address ubuntu 20

VIDEO

  1. Konfigurasi IP Address Pada Interface Ubuntu Server 22.04.3 LTS

  2. How to Configure Static IP Address on Ubuntu 22 04

  3. How to Set Static IP in Ubuntu Server 20.04 & Create New User |Hindi|

  4. Configure IP address to PC in GNS3 #gns3 #networkengineer #networkengineerstuff #ipaddresstoPCGNS3

  5. How To Configure Static IP in Ubuntu 18.04 Desktop

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

COMMENTS

  1. How to Configure Static IP Address on Ubuntu 20.04

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

  3. Configure Static IP Address on Ubuntu 20.04 (Server CLI and Desktop)

    Specify the static IP address of the server. in the addresses : section, specify an IPv4 address to be assigned to the network interface. Next, Specify the gateway. Under nameservers, specify the DNS or IP addresses of the nameservers. Here, we have specified Google's DNS which is 8.8.8.8 and the Router's IP.

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

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

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

    Login to your desktop environment and click on network icon and then choose wired settings. In the next window, Click on ' gear box ' icon under wired option, 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.

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

  8. Configure Static IP Address on Ubuntu 22.04|20.04|18.04

    Method 1: Manually edit Network Configuration files To get a Static Ip Address on Ubuntu server 22.04|20.04|18.04, you'll edit interfaces configuration file located at /etc/network/interfaces. You can use vi / vim editor or nano editor for this purpose.

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

  10. How to Configure Static IP Address on Ubuntu 20.04

    Firstly, to set up a static IP address we need to identify the name of the interface that we want to configure. For this we will use " ip_link ". $ ip link This will print out all the available network interfaces such as " enp0s3 " that we'll configure.

  11. How to Configure Static IP Address on Ubuntu 20.04

    Step 1 - Configuring the Static IP address using DHCP One of the easiest ways to assign a static IP address to the device on your LAN is to set up a static DHCP server on your router.

  12. How to Configure Networking in Ubuntu 20.04 with NetPlan

    How to Set Static IP Address. The following is an example Netplan file with a network interface that has a static IP address. The interface's name is en01 and it has been assigned static IP addresses 192.168.1.25/24 for IPv4, and 2001:1::1/64 for IPv6. As both IPv4 and IPv6 have been assigned static IP addresses, each has a gateway set too.

  13. How to Configure Static IP Address on Ubuntu 20.04

    $ sudo nano /etc/netplan/00-installer-config.yaml to replace the content of /etc/netplan/00-installer-config.yaml above with these lines. network: ethernets: ens33: addresses: [192.168.1.100/24] gateway4: 192.168.1.1 nameservers: addresses: [192.168.1.1, 8.8.8.8] version: 2

  14. How to Configure a Static IP Address on Ubuntu 20.04/22.04 LTS

    1. Get the Current Network Configuration First, we'll want to check the current IP address, subnet mask, gateway, and DNS servers on the eth0 interface: IP=$ (ip addr show eth0 | grep...

  15. Configuring Ubuntu 20.04 to use a Static IP Address

    The best possible way to set a static IP address to your Ubuntu 20.04 device is to use DHCP reservation. DHCP reservation is a feature built-in to most routers and allows you to set a specific IP. Basically, this feature ensures that the router keeps the IP address aside and only hands it to your device.

  16. Setting a Static IP in Ubuntu

    Step 1: Launch the terminal You can launch the terminal using the shortcut Ctrl+ Shift+t. Step 2: Note information about the current network We will need our current network details such as the current assigned IP, subnet mask, and the network adapter name so that we can apply the necessary changes in the configurations.

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

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

  18. How to Configure Static IP Address on Ubuntu 20.04

    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.

  19. How to Assign Static IP Address on Ubuntu Linux

    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.

  20. How to Set Static IP Address on Ubuntu Linux

    Netplan Configuration Files. It is advisable to create a backup of the default netplan configuration file as follows. $ sudo cp 01-network-manager-all.yaml 01-network-manager-all.yaml.bk. Next, run the command below to confirm the name of the network interface for which you want to set an IP address. $ ip addr sh.

  21. Configuring networks

    To temporarily configure an IP address, you can use the ip command in the following manner. Modify the IP address and subnet mask to match your network requirements. sudo ip addr add 10.102.66.200/24 dev enp0s25 The ip can then be used to set the link up or down. ip link set dev enp0s25 up ip link set dev enp0s25 down

  22. How to configure a static IP address on Ubuntu 20.04

    How to configure a static IP address on Ubuntu 20.04: Set a static IP address: Find the correct interface name: Backup the networking file. Edit the 00-installer-config.yaml file to set the static IP Address.

  23. How to set a static internal IP in Ubuntu

    If you're connected to the internet via Wi-Fi, choose Wi-Fi.If you're connected via Ethernet, select Network.; Once the interface is open, click the settings icon next to the network you're ...

  24. Mastering Remote Desktop Ubuntu: A Step-by-Step Guide

    Step 3: Get the IP address of your Ubuntu computer. To get the IP address of your Ubuntu computer for remote desktop access: Using Terminal Commands. Open the Terminal using Ctrl + Alt + T. Type ip addr show or ifconfig and press Enter. Look for the network interface (like "eth0" or "wlan0") and find the associated IP address under "inet" or ...

  25. 5 Commands to Get IP Address Information on Linux

    Like "ip addr" this one can also be used to display IP address information for all active network interfaces. ifconfig 3. hostname -I. Those who don't want detailed info about their Linux system network interfaces, instead of only the IP addresses assigned to them on the system, can use the hostname command with the "-I" option. This ...

  26. How to Configure Static IP Address on Ubuntu 20.04

    Configuring Static IP address on Ubuntu Server # On Ubuntu 20.04, the system identifies network interfaces using 'predictable network interface names'. The first step toward setting up a static IP address is identifying the name of the ethernet interface you want to configure. To do so, use the ip link command, as shown below: ip link

  27. Setting Up GPT4All on Ubuntu/Debian Linux

    Follow these steps to install the GPT4All command-line interface on your Linux system: Install Python Environment and pip: First, you need to set up Python and pip on your system. Open a terminal and execute the following command: $ sudo apt install -y python3-venv python3-pip wget. This step ensures you have the necessary tools to create a ...