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

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

The output is wider than the terminal window. This is the information that we're shown.

  • Name : Our network connection is called "netplan-enp0s3."
  • UUID : The universally unique identifier Linux uses to reference this connection internally.
  • Type : This is an ethernet connection.
  • Device : This connection is using the "enp0s3" network interface. It's the only network card in this computer.

We can use the ip command to discover the IP address this computer is using.

In the output we can see the "enp0s3" entry, and its current IP address, 192.168.86.117. The "/24" is a shorthand way of saying that this network uses a 255.255.255.0 subnet mask . Take a note of this number, we'll need to use it later.

We need to choose the IP address we're going to set as our static IP address. Obviously, you can't use an IP address that is already in use by another device. One safe way to proceed is to use the current IP address assigned to the Ubuntu system. We know for certain that nothing else is using that IP address.

If we want to use a different IP address, try pinging it. We're going to test whether IP address 192.168.86.128 is in use. If everything else on your network uses DHCP and you get no response to the ping command, it should be safe to use.

ping 192.168.86.128

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

We also need to know the IP address of your default gateway , which will usually be your broadband router. We can find this using the ip command and the route option, which we can abbreviate to "r."

The entry that starts with "default" is the route to the default gateway. Its IP address is 192.168.86.1. Now we can start to issue commands to set up our static IP address.

The first command is a long one.

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

Taken in small chunks, it's not as bad as it looks. We're using sudo . The nmcli arguments are:

  • con : Short for "connection."
  • add : We're going to add a connection.
  • con-name "static-ip" : The name of our new connection will be "static-ip."
  • ifname enp0s3 : The connection will use network interface "enp0s3."
  • type ethernet : We're creating an ethernet connection.
  • ip4 192.168.86.128/24 : The IP address and subnet mask in classless inter-domain routing notation . This is where you need to use the number you took note of earlier.
  • gw4 192.168.86.1 : The IP address of the gateway we want this connection to use.

To make our connection a functioning connection, we need to provide a few more details. Our connection exists now, so we're not adding anything, we're modifying settings, so we use the mod argument. The setting we're changing is the IPv4 DNS settings. 8.8.8.8 is the IP address of Google's primary public DNS server , and 8.8.4.4 is Google's fallback DNS server.

Note that there is a "v" in "ipv4." In the previous command the syntax was "ip4" without a "v." The "v" needs to be used when you're modifying settings, but not when adding connections.

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

To make our IP address static, we need to change the method which the IP address obtains its value. The default is "auto" which is the setting for DHCP. We need to set it to "manual."

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

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

nmcli con up "static-ip" ifname enp0s3

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

nmcli con show

Here's the output:

Our static-ip connection is active and using device "enp0s3." The existing connection "netplan-enp0s3" is no longer associated with a physical network interface because we've pinched "enp0s3" from it.

Click the icons at the far-right end of the system bar to show the system menu, then click on the "Wired Connected" menu option. If you're using a wireless connection, instead click the name of your Wi-Fi network.

The available connections are displayed. A dot indicates which is in use. Click the "Wired Settings" or "Wi-Fi Settings" menu option. The details of the active connection are displayed.

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

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

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

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

Select the "Manual" radio button, and complete the "Address", "Netmask", and "Gateway" fields. Also complete the DNS field, and then click the green "Apply" button. Note the comma between the DNS entries.

Our new connection is listed in the "Wired" connections pane.

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

If you want to modify a connection after you create it, click the cog icon. In this case, we'll enter the settings for the "static-ip" connection.

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

Because we set our new IP address to be static, the "Manual" radio button is selected. You could change this back to DHCP by selecting the "Automatic (DHCP)" radio button, and clicking the green "Apply" button.

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.

Setting a Static IP in Ubuntu – Linux IP Address Tutorial

Zaira Hira

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

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.

change ip address in Ubuntu Linux in 3 ways

By: Author Archit Modi

Posted on Last updated: February 20, 2023

Categories network

If you’re using Ubuntu Linux, there are three different ways that you can change your IP address.

Which method you use will depend on whether you want to change your address permanently or just temporarily.

In either case, I’ll walk you through the steps so that you can get started right away.

change ip address in Ubuntu Linux with ip addr command

The first method is to use the “ip addr” command in a terminal window. This will allow you to easily change your IP address with just one command. To do this, open up a terminal and type the following:

sudo ip addr add 192.168.1.100/24 dev eth0

This will add another IP address 192.168.1.100 with a subnet mask of 255.255.255.0, assuming that eth0 is the network interface you want to change the address on.

Note: You should replace eth0 with the name of your network interface if it is different, such as wlan0 for a wireless connection.

The disadvantage of using this command is that the changes are not permanent. If you restart your computer or networking service, the IP address will be reset to its original setting.

However, if you need to change the IP address quickly and don’t want to reboot or restart services, then this is a good option.

Another thing we need to pay attention to is that we need to delete the old ip address manually.

To delete an IP address manually, you’ll need to use the “ip addr del” command. This will allow you to delete a specific IP address from your network interface.

For example, if I need to delete 192.168.1.101 from eth0, then I will type the following into a terminal:

sudo ip addr del 192.168.1.101/24 dev eth0

change ip address in Ubuntu Linux with network-manager

The second way to change your IP address on Ubuntu is to use the Network Manager. This is a graphical tool that allows you to easily configure your network settings, including changing your IP address. To do this, open up the Network Manager by clicking on the icon in your taskbar or searching for it in Dash.

Once you’re in the Network Manager, select your network connection and click “Edit”. You should then see an option to change your IP address. Enter the new one and click “Apply” to save the changes.

change ip address in Ubuntu Linux with netplan

The last method to change your IP address in Ubuntu is to use the Netplan tool. This is a new network configuration tool that was introduced in Ubuntu 17.10 and is available for all newer versions of the operating system.

To use Netplan to change your IP address, you’ll need to create a configuration file in the /etc/netplan directory. This file should have the .yaml extension.

For example, if I want to call it mynetwork.yaml, then I will type the following into the terminal: sudo nano /etc/netplan/mynetwork.yaml

Once I have the configuration file open, I’ll need to set the IP address for my network interface. This should look something like this:

 ethernets:

  enp0s3:

   addresses: [192.168.100.50/24]

   gateway4: 192.168.100.1

   nameservers:

    addresses: [192.168.100.1, 192.168.100.2]

 version: 2

Make sure to replace enp0s3 with the name of your network interface and enter the IP address you want to use instead of 192.168.100.50.

Once it is done, save the configuration file and then type the following into a terminal to apply the changes:

sudo netplan apply

This will change your IP address to the one we specified in the configuration file immediately. The advantage of using this method is that the changes are permanent and will persist across reboots or service restarts.

You should then see the new address listed when you type:

Your IP address can be changed with either of these three methods! Remember that if you’re using the ip addr, the changes are not permanent and will be lost when you restart or reboot your system.

If you want to make the changes permanent, then you’ll need to use the netplan command.

Once you’ve changed your IP address, it’s important to test that everything is working as expected. You can do this by pinging another device on your network or attempting to connect to the Internet. You should also check that other devices on your network are able to access your computer.

If everything is working correctly, then you have successfully changed your IP address in Ubuntu! Congratulations!

Set static IP in Ubuntu using Terminal

Everything you need to know about setting static IP on an Ubuntu machine using the command line.

Dec 5, 2022 — Pratham Patel

Normally, the router's DHCP server handles assigning the IP address to every device on the network, including your computer.

The DHCP server may also give you a new IP address occasionally. This could cause a problem if you have a home lab or server setup that works on a fixed IP address.

You need to set a static IP address on your Ubuntu system to avoid problems.

Step 1: Identify the correct network interface

The first step is always to know the name of your network interface.

"But why?" you might ask. That is because since Ubuntu 20.04, the network interfaces are named using predictable network interface names . This means your one and only ethernet interface will not be named 'eth0'.

Ubuntu Server and Ubuntu Desktop use different renderers for 'netplan', they are 'systemd-networkd' and 'NetworkManager', respectively. So let's go over their differences.

Ubuntu Server

To see available network interfaces on Ubuntu Server, run the following command:

Doing so will show a similar result:

The output enumerates network interfaces with numbers.

From this, I can see that the ethernet interface is 'enp1s0'.

Ubuntu Desktop

The advantage (at least in my opinion) of having Ubuntu Desktop is having NetworkManager as the renderer for netplan .

It has a pretty CLI output :)

Run the following command to view the available network interfaces:

That will give you the device name, type, state and connection status.

Here is what it looks like on my computer:

This is more readable at first glance. I can make out that my ethernet interface is named 'enp1s0'.

how to change ip address in linux ubuntu

Step 2: See current IP address

Now that you know which interface needs to be addressed, let us edit a file .

Before I change my IP address/set a static one, let us first see what my current IP address is .

Nice! But let's change it to '192.168.122.128' for demonstration purposes.

Step 3: See the gateway

A gateway is a device that connects different networks (basically what your all-in-one router is). To know the address of your gateway, run the following command:

The gateway address will be on the line that begins with "default via".

Below is the output of running the ip command on my computer:

On the line that starts with "default via", I can see that my gateway address '192.168.122.1'

Make a note of your gateway address.

Step 4: Set static IP address

Now that you have detail like interface name and gateway address, it is time to edit a config file.

Step 4-A: Disable cloud-init if present

The easiest way to know if cloud-init is present or not is to check if there is a package with that name.

Run the following command to check:

If you get an outupt, you have 'cloud-init' installed.

Now, to disable could-init, create a new file inside the /etc/cloud/cloud.cfg.d directory. The name does not matter, so I will call it '99-disable-cloud-init.cfg'.

Add the following line to it:

Please reboot your Ubuntu system now so that cloud-init does not interfere when we set our static IP address in the next step. :)

Back to Step 4

Once the 'cloud-init' related configuration is complete, we must now edit the netplan configuration to add our static IP address.

Go to the /etc/netplan directory. It is better if there is one file (easier to know which one to edit), but in some cases, there might also be more than one file with the extension '.yml' or '.yaml'.

When in doubt, grep for the name of your network interface. Use the following command if you are not comfortable with grep:

Since the name of network interface for my ethernet is 'enp1s0', I will run the following command:

running this command shows that the file I am looking for is '00-installer-config.yaml'. So let us take a look at it.

You might have noticed a line that says 'ethernet' and our network interface name under that. Under this is where we configure our 'enp1s0' network interface.

Since we do not want DHCP assigned IP address, let us change that field from true to no .

Add a field called addresses . Write the IP address you wish to assign your computer along with the network prefix. So I will write 192.168.122.128/24 in the addresses field.

Finally, we also need to specify DNS nameservers. For that, create a new field called nameservers and under that, create a field called addresses which contains the IP address for your DNS servers . I used Cloudflare's DNS servers but you can use whatever you want.

This is what my '00-installer-config.yaml' file looks like after editing it to my liking.

To apply the settings, run the following command:

This will take only a few seconds, and the IP address will be updated once it is done.

You can check the IP address using the hostname -I command.

Perfect! The IP address has now changed successfully.

how to change ip address in linux ubuntu

I know that it feels complicated but this is the proper procedure when you are trying to assign static IP via the command line in Ubuntu.

Let me know if you are stuck at some point or encounter any technical issues.

Pratham Patel

Fell in love with Ubuntu the first time I tried it. Been distro-hopping since 2016.

On this page

Network Settings

How to change ip address on ubuntu.

change ip address ubuntu

IP address assignment is typically handled by a DHCP server. You can request the server to end the DHCP lease and release your device’s current IP address. Depending on how the server is configured, your device may or may not be assigned a different IP address with this method.

Another way to change your IP address is with DHCP reservation. But that’s a feature that’s configured from your router settings. Instead of such methods, we’ll specifically cover ways to change your IP address directly from Ubuntu in this article.

The easiest way to change your IP address on Ubuntu is via the NetworkManager GUI.

ubuntu settings app

Netplan is used to configure networking on Linux systems through the networkd or NetworkManager backends. It reads the configuration from a YAML description file and hands off device control to the specified networking daemon.  

To change your IP address, you’ll need to modify the netplan config file. The default config file named 01-network-manager-all.yaml or 50-cloud-init.yaml can be found in the /etc/netplan directory. 

First, check the interface’s logical name.

Open the config file with a text editor like nano.

Use the configuration provided below. Ensure the number of prefix spaces is correct as shown here or the config won’t work.  

We’re using NetworkManager as the backend here. We specified enp1s0 as the Ethernet interface and DHCP is disabled . Then, we set the interface’s IP address with a Class C subnet prefix length ( 192.168.122.50/24 ).

We then set the gateway , defined it via a default route , and finally set the DNS servers . Remember to change these values as appropriate for your own network. After your configuration looks good, apply the new config with

You can verify the changes with

IP Address changes made by the previous two methods were persistent. But if you only want to make a temporary IP change that’ll revert upon connection reset, you can use the ip command.

First, identify the interface.

Use the add option to add a new IP address to the interface. Remember to adjust the IP address and interface name values.

Remove the old IP address with del option like so

Here, we changed the IP address of the enp1s0 interface from 192.168.122.11 to 192.168.122.186 . Once again, you can verify the change with

Ubuntu desktops use the NetworkManager daemon by default, whereas Ubuntu servers normally handle network configuration with networkd . On such systems, you can edit the network configs in /etc/systemd to change your IP address.

Use the following configuration and adjust the interface name, IP address, gateway, and DNS values as you require.

Save the new configuration and restart the networkd service to apply the changes.

You can also use NetworkManager’s command-line version ( nmcli ) to manage network configurations such as your IP address.

First, list your connections and note the connection name.

You can directly change the IP address configuration, replacing the values with your own like so

We identified that we need to modify Wired connection 1 with the previous command. Then, we set the IPv4 method to manual and set the IP address with prefix , gateway , and DNS values.

Finally, activate the connection and verify the change with

This is sufficient for basic configuration, but nmcli is a highly versatile tool. If you want to learn to make advanced config changes, we recommend using the interactive editor.

The editor will display which settings you can edit (connection profile, ipv4, proxy, etc). Enter help to list the available commands (set, print, describe, save, quit, etc). Enter print ipv4 to list the modifiable IPv4 settings and properties.

You can use the describe command to view the documentation for each setting (e.g., describe ipv4, describe ipv4.addresses). Now, use the set command to set the property values like so

Save the connection with save persistent or save temporary . Then, enter quit to exit nmcli and verify the new config with

Senior Writer

Anup Thapa is a Linux enthusiast with an extensive background in computer hardware and networking. His goal is to effectively communicate technical concepts in a simplified form understandable by new Linux users. To this end, he mainly writes beginner-friendly tutorials and troubleshooting guides. Outside of work, he enjoys reading up on a range of topics, traveling, working out, and MOBAs.

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 to permanently change the IP address of Ubuntu with CLI only?

I have a ubuntu machine and want to change the IP address, the requirements are as follow:-

  • using only cli to change the IP address, since the HW is not accessible and the script is changing the IP address through SSH, so it has to be the only cli
  • The changes to be permanent, the IP address shouldn't be lost on restart
  • This should be applicable to all the version of ubuntu

The ubuntu in question is a VM with the default static IP already configured can be accessed with the SSH.

Is there any way to change the IP address of ubuntu with the above requirement?

preferably it should be supported from version 14 - 20 (only stable build)

  • command-line

rahul  Kushwaha's user avatar

  • How did you get the original address, the one you are trying to change? DHCP, ifupdown, static, netplan ... –  Eduardo Trápani May 26, 2020 at 5:27
  • it is snapshot of VM, hence IP is pre-configured, need to change that. –  rahul Kushwaha May 26, 2020 at 5:28
  • yes, its static IP allocation –  rahul Kushwaha May 26, 2020 at 5:29
  • To start with, which release number? Different releases have different tools for us to recommend. Please click edit & add that to your question, so all facts we need are in the question. Please don't use Add Comment, since that's our one-way channel to you. All facts about your PC should go in the Question with edit as this is a Q&A site, not a general forum, so things work differently here. –  K7AAY May 26, 2020 at 17:04

2 Answers 2

Two (of many ways) to do it, say you want the new IP to be 192.168.80.10 with netmask 255.255.255 and your interface is eth0

or, with the newer ip command, you remove the old address and add the new one:

Eduardo Trápani's user avatar

  • will it, instantly apply the IP address? –  rahul Kushwaha May 26, 2020 at 5:42
  • @rahulKushwaha yes –  Eduardo Trápani May 27, 2020 at 20:50
  • 3 This won't be permanent though, it won't survive a reboot –  Bob Vale Oct 19, 2022 at 9:42
  • As @BobVale stated, this didn't survive a reboot. So I found a way and shared it here –  Pedram May 1, 2023 at 9:23

I did try with the ip method shared here , but it did not survive reboots. So, I figured, since the Network Manager was managing stuff, things went back to default 🌊

Change ip and netmask with nmcli

Network Manager is installed by default on ubuntu machines so you have access to nmcli . Here is what might work for you:

Check current settings with executing only nmcli . Take note on connection type (e.g. ethernet), DNS Configuration (i.e. servers), and the interface you are connecting to.

Create a new connection

Let's assume you want to create a connection which has the following properties:

  • Name: SOME_NAME
  • Interface: enp0s31f6
  • The interface enp0s31f6 is a cable connection, so type is: ethernet
  • You want to set the static ip 172.18.1.30 , so set it as ip4 value and also set ipv4.type as manual .
  • The default gateway and dns are already shown when entering nmcli , if you are not planning to change it, just copy them here as values after gw4 and ipv4.dns ,
Note that autocomplete should work, so you can simply check for things such as interface-name by pressing TAB twice.

Now, the changes should be permanent 🔒

This answer was inspired by this HTG post .

Pedram's user avatar

  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center . –  Community Bot May 1, 2023 at 10:30

You must log in to answer this question.

Not the answer you're looking for browse other questions tagged command-line networking server ip ..

  • The Overflow Blog
  • Reshaping the future of API platforms
  • Between hyper-focus and burnout: Developing with ADHD
  • Featured on Meta
  • Our Partnership with OpenAI
  • Imgur image URL migration: Coming soon to a Stack Exchange site near you!

Hot Network Questions

  • printf - store formatted string output in a variable
  • Can individual rings of Saturn be considered satellites?
  • How did the bugs get all over the place?
  • Isn't the fundamental group a hom functor?
  • Looked at a different rolling (3d6, 3d6, average) for D&D characters in AnyDice and the result didn't come out as expected. What am I missing?
  • Scientist travels back in time to murder his wife’s secret lover
  • Shortest battleship game, to find number of battleships
  • What can you use in your soil to kill bugs before planting vegetables?
  • code format and steps web scraping using beautiful soup
  • On Pareto functions
  • Similar research paper
  • The Wu line drawing algorithm for anti-aliased lines optimization
  • I keep blowing up irrigation solenoids
  • Is there any explanation or discussion regarding the change in the Bard class from its AD&D1ed orignal implementation?
  • Is the meter relative to time?
  • What is the equation relating the sides and the orthocenter segments of a triangle?
  • Is science value-free?
  • What's the story behind the "mysterious" 486DX3?
  • *Trivial* near-repdigit perfect powers
  • Is the estimand in a Regression Discontinuity Design the ATE, ATT, etc?
  • Immigration and customs requirements on entering JFK (self-transfer)
  • Material works like light & lights up surrounded objects
  • How is the argument (#1) in \DeclareNameWrapperFormat interpretted?
  • How does the centripetal force change when the radius changes?

how to change ip address in linux ubuntu

How to Configure Static IP Address on Ubuntu 24.04 (Desktop)

In this article, we will show you how to configure static ip address on Ubuntu 24.04 desktop step by step.

When you want a persistent IP address on your Ubuntu 24.04 desktop, then you must a configure a static IP address. Whenever we install Ubuntu then DHCP is enabled by default, and it will try to fetch the IP address from DHCP server if it is available over the network.

In Ubuntu Desktop 24.04, there are two ways to configure static IP address:

  • Graphical User Interface
  • Command Line

We will cover both the methods in this article.

Prerequisites

  • Pre-Install Ubuntu 24.04
  • Regular user with sudo rights
  • Basic understanding of networks

Configure Static IP Address on Ubuntu 24.04 Using GUI

Login to your desktop, click on the network icon and then choose Wired option as shown below:

Wired-Network-Settings-Ubuntu-24-04

We will get the following window, click on “ gearbox” icon

Gearbox-Icon-Ubuntu-24-04-Network-WiredSettings

Go to IPv4 tab, there you will see that DHCP is enabled for automatic IP allocation.

Automatic-DHCP-Option-Ubuntu-24-04-Network-Settings-GUI

Choose Manual option to configure static IP address and specify IP details (IP address, netmask, gateway and DNS IP) as show below:

Note: Change the IP details that suits to your network

Configure Static IP Address On Ubuntu 24.04

Click on Apply .

Next, disable and enable the interface to make above changes into effect.

Above screen confirms that we have successfully configured static IP address on our Ubuntu 24.04 desktop.

Configure Static IP Address on Ubuntu 24.04 Using Command Line

We can use netplan utility and its configuration file to assign the static ip on the interface (like ep0s3 or eth0).

Netplan configuration file are placed in /etc/netplan directory. Under this directory there should be a file with name 01-netcfg.yaml , 50-cloud-init.yaml or may be else depending on your environment.

Netplan-Configuration-file-Ubuntu-24-04-Desktop

Edit netplan configuration file, in our case it is 01-netcfg.yaml

save and close the file.

Note: In above file, replace the IP address details and interface according to your setup. We have also used renderer as “ NetworkManager ” which instructs netplan to use NetworkManager as its backend. It is used for desktops and for the servers and headless environments use “ networkd ” instead of NetworkManager.

Configure Static IP Address On Ubuntu 24.04 Command Line

Set the permission on this file using chmod command,

To make above changes into the affect, run below netplan apply command.

Next, verify the IP address and network connectivity.

Verify-IP-Details-Ubuntu-24-04-Desktop

Perfect, output above shows that we have successfully configure static ip address using netplan utility.

That’s all from this article. We hope you have found it informative and useful, feel free to post your queries and feedback in below comments section.

Read Also : How to Install Git on Ubuntu 24.04

Leave a Comment Cancel reply

how to change ip address in linux ubuntu

How to change the hostname on Ubuntu

I f you've ever set up a Linux distribution like Ubuntu , you may have noticed the installer prompts you to enter a name for your machine. Commonly called the hostname, it's the name that identifies your Linux system every time you connect to another device over a network or Bluetooth connection.

After reviewing all the settings, toggles, and options during the installation procedure, you may have accidentally entered the wrong hostname. But don't worry — Ubuntu lets you change your system's hostname via GUI and a variety of terminal commands .

These steps will be for Ubuntu 23.04, but should be pretty similar to other versions of Ubuntu.

Best laptops for Linux in 2024

How to change the hostname on ubuntu with the settings app.

Similar to the process on Windows 11, if you want to change the hostname of an Ubuntu system, you can just head into the Settings app. The GUI makes it easy, which is the method we suggest most people use.

  • Click on the power button and choose Settings .
  • Scroll down to About and click the arrow next to the Device Name.
  • Enter the new hostname and press the Rename button. .

You don't need to restart your system after changing the hostname. The change should take effect right away. Some apps might not see the name change, though, and if this is the case, simply reboot your PC.

How to change the hostname on Ubuntu with the terminal

More advanced Ubuntu users might want to change the hostname using the terminal. This method requires you to enter a few commands. You won't have to reboot your system, either.

  • Press Ctrl+Alt+T to open the terminal.
  • Type the command: hostnamectl set-hostname new-hostname Be sure to replace new-hostname with the actual hostname you want to use.

You won't see any results or be prompted for passwords. This is totally normal. You can confirm the hostname was indeed changed with the command hostnamectl.

How to run an Ubuntu virtual machine on Apple Silicon for free

How to change the hostname on ubuntu via configuration files.

Since Ubuntu uses the hostname and host configuration files to store the name of your PC, you can rename it by replacing the old hostname with the name you wish to give your system.

  • Inside the terminal, type the following command to open the hostname file using the nano editor: sudo nano /etc/hostname
  • Overwrite the older name with the new hostname.
  • Press Ctrl+X to exit the file. Be sure to tap Y when prompted to save the changes.
  • Open the hosts config file using this command: sudo nano /etc/hosts
  • Rename the string adjacent to the 127.0.1.1 IP address to the new hostname.
  • Hit Ctrl+X followed by Y to save and exit the hosts file.
  • (Optional) If you're running Ubuntu as a cloud instance with the help of the cloud-init utility, you'll need to modify a third config file called cloud.cfg. Simply open the file with this command and ensure the preserve_hostname string has the value true assigned to it. sudo nano /etc/cloud/cloud.cfg

After using this method, you'll need to restart your system for Ubuntu to reflect the hostname changes.

How to temporarily change the hostname on Ubuntu

If you don't want the hostname change to be permanent and just want to change for one time only, you can head into the terminal to swap names. Of course, you can check the actual hostname first, too, which we'll cover here. As a reminder, you'll have to press Enter after each command.

  • Open a terminal session.
  • To change the hostname temporarily, type the command: sudo hostname new-hostname Again, don't forget to replace new-hostname with the actual hostname you want to use.
  • Enter your password when prompted by Ubuntu.

Once you finish, you can confirm the hostname was changed with the hostname command.

What hostname did you pick for your Ubuntu PC?

Those are all the ways you can change the hostname on Ubuntu. Apart from the last method, every other procedure results in a permanent change in the hostname, though you can modify it as many times as you wish.

If you're curious about Ubuntu, be sure to check out our detailed setup guide for the OS . We also have other articles that may interest developers, such as those on configuring environment variables and installing Anaconda and AWS CLI on Ubuntu .

How to change the hostname on Ubuntu

Change the hostname of your AL2 instance

When you launch an instance into a private VPC, Amazon EC2 assigns a guest OS hostname. The type of hostname that Amazon EC2 assigns depends on your subnet settings. For more information about EC2 hostnames, see Amazon EC2 instance hostname types in the Amazon EC2 User Guide for Linux Instances .

A typical Amazon EC2 private DNS name for an EC2 instance configured to use IP-based naming with an IPv4 address looks something like this: ip-12-34-56-78.us-west-2.compute.internal , where the name consists of the internal domain, the service (in this case, compute ), the region, and a form of the private IPv4 address. Part of this hostname is displayed at the shell prompt when you log into your instance (for example, ip-12-34-56-78 ). Each time you stop and restart your Amazon EC2 instance (unless you are using an Elastic IP address), the public IPv4 address changes, and so does your public DNS name, system hostname, and shell prompt.

This information applies to Amazon Linux. For information about other distributions, see their specific documentation.

Change the system hostname

If you have a public DNS name registered for the IP address of your instance (such as webserver.mydomain.com ), you can set the system hostname so your instance identifies itself as a part of that domain. This also changes the shell prompt so that it displays the first portion of this name instead of the hostname supplied by AWS (for example, ip-12-34-56-78 ). If you do not have a public DNS name registered, you can still change the hostname, but the process is a little different.

In order for your hostname update to persist, you must verify that the preserve_hostname cloud-init setting is set to true . You can run the following command to edit or add this setting:

If the preserve_hostname setting is not listed, add the following line of text to the end of the file:

To change the system hostname to a public DNS name

Follow this procedure if you already have a public DNS name registered.

For AL2: Use the hostnamectl command to set your hostname to reflect the fully qualified domain name (such as webserver.mydomain.com ).

For Amazon Linux AMI: On your instance, open the /etc/sysconfig/network configuration file in your favorite text editor and change the HOSTNAME entry to reflect the fully qualified domain name (such as webserver.mydomain.com ).

Reboot the instance to pick up the new hostname.

Alternatively, you can reboot using the Amazon EC2 console (on the Instances page, select the instance and choose Instance state , Reboot instance ).

Log into your instance and verify that the hostname has been updated. Your prompt should show the new hostname (up to the first ".") and the hostname command should show the fully-qualified domain name.

To change the system hostname without a public DNS name

For AL2: Use the hostnamectl command to set your hostname to reflect the desired system hostname (such as webserver ).

For Amazon Linux AMI: On your instance, open the /etc/sysconfig/network configuration file in your favorite text editor and change the HOSTNAME entry to reflect the desired system hostname (such as webserver ).

Open the /etc/hosts file in your favorite text editor and change the entry beginning with 127.0.0.1 to match the example below, substituting your own hostname.

You can also implement more programmatic solutions, such as specifying user data to configure your instance. If your instance is part of an Auto Scaling group, you can use lifecycle hooks to define user data. For more information, see Run commands on your Linux instance at launch and Lifecycle hook for instance launch in the AWS CloudFormation User Guide .

Change the shell prompt without affecting the hostname

If you do not want to modify the hostname for your instance, but you would like to have a more useful system name (such as webserver ) displayed than the private name supplied by AWS (for example, ip-12-34-56-78 ), you can edit the shell prompt configuration files to display your system nickname instead of the hostname.

To change the shell prompt to a host nickname

Create a file in /etc/profile.d that sets the environment variable called NICKNAME to the value you want in the shell prompt. For example, to set the system nickname to webserver , run the following command.

Open the /etc/bashrc (Red Hat) or /etc/bash.bashrc (Debian/Ubuntu) file in your favorite text editor (such as vim or nano ). You need to use sudo with the editor command because /etc/bashrc and /etc/bash.bashrc are owned by root .

Edit the file and change the shell prompt variable ( PS1 ) to display your nickname instead of the hostname. Find the following line that sets the shell prompt in /etc/bashrc or /etc/bash.bashrc (several surrounding lines are shown below for context; look for the line that starts with [ "$PS1" ):

Change the \h (the symbol for hostname ) in that line to the value of the NICKNAME variable.

(Optional) To set the title on shell windows to the new nickname, complete the following steps.

Create a file named /etc/sysconfig/bash-prompt-xterm .

Make the file executable using the following command.

Open the /etc/sysconfig/bash-prompt-xterm file in your favorite text editor (such as vim or nano ). You need to use sudo with the editor command because /etc/sysconfig/bash-prompt-xterm is owned by root .

Add the following line to the file.

Log out and then log back in to pick up the new nickname value.

Change the hostname on other Linux distributions

The procedures on this page are intended for use with Amazon Linux only. For more information about other Linux distributions, see their specific documentation and the following articles:

How do I assign a static hostname to a private Amazon EC2 instance running RHEL 7 or Centos 7?

Warning

To use the Amazon Web Services Documentation, Javascript must be enabled. Please refer to your browser's Help pages for instructions.

Thanks for letting us know we're doing a good job!

If you've got a moment, please tell us what we did right so we can do more of it.

Thanks for letting us know this page needs work. We're sorry we let you down.

If you've got a moment, please tell us how we can make the documentation better.

How to Fix DNS_PROBE_FINISHED_NXDOMAIN

Fix DNS_PROBE_FINISHED_NXDOMAIN in Linux & Windows

You have undoubtedly encountered the “DNS_PROBE_FINISHED_NXDOMAIN” error at least once during web surfing. You know how the continuous occurrence of this error while accessing various websites can be frustrating. The “ DNS_PROBE_FINISHED_NXDOMAIN ” error is one of the common and familiar errors encountered during web browsing. It occurs when the DNS server encounters a problem resolving the domain name to an IP address. Consequently, this issue prevents access to the desired website and displays this error in your browser.

The occurrence of the “DNS_PROBE_FINISHED_NXDOMAIN” error in Linux and Windows can have various causes, including DNS server issues, incorrect DNS settings, or network configuration problems. In this article, we intend to teach practical methods for troubleshooting and resolving the “DNS_PROBE_FINISHED_NXDOMAIN” error in Linux and Windows so that your web browsing does not become more exhausting. If you’re ready, let’s delve into expert troubleshooting of DNS server and network problems.

Table of Contents

What does the “DNS_PROBE_FINISHED_NXDOMAIN” error mean?

The “DNS_PROBE_FINISHED_NXDOMAIN” error is a message web browsers display when the DNS server cannot resolve the domain name to an IP address. To better understand this error, let’s break down its components and analyze it to diagnose the problem more quickly.

what is "DNS_PROBE_FINISHED_NXDOMAIN" error

DNS (Domain Name System) : DNS is a system that translates human-readable domain names into their respective IP addresses to facilitate communication between devices on a network when accessing websites over the Internet.

PROBE : In networking terminology, “probe” refers to a test or inquiry made to gather information about a system or network.

FINISHED : Indicates the termination of the DNS lookup process.

NXDOMAIN : NXDOMAIN stands for “Non-Existent Domain,” indicating that the domain being queried does not exist in the DNS system. The DNS server could not find a record for the domain name.

Therefore, this error indicates that the DNS server failed to obtain a record or any information for the domain you are attempting to access.

Reasons for the DNS_PROBE_FINISHED_NXDOMAIN error occurrence

After purchasing a VPS running Linux or Windows, you may encounter the “DNS_PROBE_FINISHED_NXDOMAIN” error when trying to access various websites. In this section of the article, you will identify common reasons for this error and fix your issues quickly with the solutions we will provide.

Various reasons cause the “DNS_PROBE_FINISHED_NXDOMAIN” error to appear in the web browser. Here, we will mention the underlying  reasons that lead to the occurrence of the “DNS_PROBE_FINISHED_NXDOMAIN” error:

  • Typo in the domain name and website address
  • DNS server issues like DNS misconfiguration
  • Domain not registered or has been removed or expired
  • network connectivity issues
  • VPN or antivirus problems
  • DNS cache issues such as outdated or incorrect DNS entries on your device
  • Firewall or security settings

Solutions to fix DNS_PROBE_FINISHED_NXDOMAIN error in windows and linux

Now that you know the common causes of the “DNS_PROBE_FINISHED_NXDOMAIN” error, you can troubleshoot and fix your problem faster and more efficiently. There are various troubleshooting tools to fix DNS errors , but this guide will teach you the most practical methods to fix the “DNS_PROBE_FINISHED_NXDOMAIN” error.

1. Restart Networking Services and Reset Network Adapter

Restarting the Networking service is one of the simplest and most basic methods to solve any problem, which often resolves the issue in most cases and has become a routine for solving problems. Although this method is the simplest, it may play a role in solving your problem. Therefore, you can reset the network services in the Windows and Linux systems to solve “DNS_PROBE_FINISHED_NXDOMAIN” errors.

You can use the following command to Restart Networking service in Linux:

  • Debian -based Linux :
  • CentOS or Red-Hat-based Linux :
  • Arch Linux :

Restarting the networking service in Linux causes a network adapter reset, which is another solution to resolve the DNS_PROBE_FINISHED_NXDOMAIN error in Linux and Windows. So, By executing the relevant command to restart the networking service in Linux, you also reset the network adapter.

For Windows:

Follow the steps below to Restart the Networking Service in Windows:

  • Press the shortcut keys Win + X and select “ Windows Terminal (Admin) ” or “ Command Prompt (Admin) .”
  • Run the following commands and then hit Enter :

Replace “Local Area Connection” with the actual name of your network interface if it’s different.

To reset the network adapter in Windows, you should follow the steps below:

  • Launch the Command Prompt by right-clicking on the Windows start button.
  • Type “ netsh winsock ” in the Windows command prompt and hit enter.
  • After running the command, restart the Windows system.

2. Check DNS Settings

Incorrect DNS configuration can disrupt DNS functionality, so it’s essential to ensure correct DNS settings. To resolve the DNS issue, check the DNS settings in both Linux and Windows.

Since the /etc/resolv.conf file contains DNS configurations in Linux, you can check the DNS configuration in Linux by running the following command:

By running this command, you can ensure the validity and reachability of the listed DNS servers. If you discover that the DNS servers are not configured correctly, you must change the DNS Server Settings in Linux .

To check the DNS settings and ensure proper configuration and the validity of available DNS servers, follow these steps in Windows:

  • Navigate to “ Network and Sharing Center ” > “ Change adapter settings .”
  • right-click on your network connection.
  • Select “ Properties ” and then “ Internet Protocol Version 4 (TCP/IPv4) ” to check your DNS settings.

3. Check Hosts File

Hosts file is a text file that your system uses every time you browse the web to match the domain name to the corresponding IP address to prevent the default DNS mapping and fetch the correct website for display. Therefore, if the Hosts File contains incorrect entries, it may lead to DNS-related issues. In some cases, malware can make changes to the Hosts File, redirecting traffic to incorrect and troublesome addresses, and preventing you from accessing the desired website.

Hence, you should check the contents of the Hosts File in both Linux and Windows to ensure that no incorrect entries exist.

Check the Hosts file In Linux (/etc/hosts file )and fix the DNS issue through the following instructions:

  • Launch Terminal.
  • Navigate to the /etc directory through the following command:
  • Open the Hosts File using your preferred text editor:
  •  It’s time to edit the Hosts File , Find the entry for the desired website in the Hosts File, and delete it.
  • Save the Hosts File and exit the nano editor.
  • Restart the Linux system and check whether you can successfully access your desired website.

The Hosts File is located at C:\Windows\System32\drivers\etc\hosts in Windows. Therefore, to check the Hosts File in Windows, follow these steps:

  • Type Notepad in the search bar, then right-click on it and choose Run as administrator to open it with administrative privileges.
  • Select the “ File ” option and click “ Open ” from the displayed menu.
  • In the filter menu, select the” All Files ” option.
  • In the File name box, enter the following path:

Checking Hosts File in windows

  • Open the Hosts File.
  • The content of this file displays a list of blacklisted websites. If your target website’s domain name and IP address are placed below the line ::1 localhost , remove it and save the file.

troubleshooting DNS_PROBE_FINISHED_NXDOMAIN error in windows

4. Flush DNS Cache

DNS caches contain information that DNS uses to improve and speed up the process of mapping various domain names to their respective IP addresses. Therefore, the DNS cache stores all the IP addresses of websites you have previously visited, which may become outdated with website information updates. These outdated IP addresses may prevent access to your desired website, therefore, Clearing the DNS cache in Windows and Linux can assist in resolving DNS resolution issues. Clearing the DNS cache ensures that up-to-date website information is stored, fixing the DNS_PROBE_FINISHED_NXDOMAIN error in Windows and Linux.

Although you have previously learned how to clear the DNS cache in Windows and Linux , we will provide a brief tutorial for this purpose in this article. However, we recommend learning this method from the previous article.

If you suspect a DNS cache issue, flush the DNS cache in popular Linux distributions, including Ubuntu , Debian, and CentOS, using the following command:

You can also use the following command to clear the DNS entries:

Use the following instructions to flush the DNS cache on Windows:

  • Find “ Command Prompt ” in the list of start menu and launch it with administrative privileges.

Run the following command and then press the Enter :

  • Launch the browser and check again if you are getting the “DNS_PROBE_FINISHED_NXDOMAIN” error when attempting to access the desired website.

5. Release and Renew IP Address

If flushing the DNS cache doesn’t resolve the DNS issue, giving up the lease to your computer’s old IP address and requesting a new one is an effective method to solve network connection issues. You can change the address provided by DHCP with Release and Renew IP Address.

To Release and Renew IP Address in Linux, follow these steps in order:

  • Open the Linux terminal by pressing the Ctrl+Alt+T shortcut keys.
  • To release the current IP, use the following command:
  • After making sure that the old client process is terminated, renew the IP address by running the following command:

Then, test connecting to the desired website to see if your problem is resolved.

Use the following steps to Release and Renew IP Address in Windows:

  • Launch command prompt as administrator
  • Release the current IP address via the following command:
  • Run the following command to check full IP configs for all the adapters:

Use the following command to reset the DNS cache:

Renew the DNS setting for all adapters through the following command and press Enter:

To reset your previous IP settings and reinstate the Winsock Catalog, run the following command:

Exit the command prompt and restart your Windows system. Then, open your browser, search for the website URL you want, and check whether your problem is solved.

 6. Clear Browser DNS Cache

Browsers, separately from the operating system, cache website data you visit to reduce search time and speed up domain name translation to the IP address. Clearing the browser’s DNS cache is a quick method to resolve DNS errors. In the following, we will provide instructions on how to flush the browser DNS cache in popular browsers like Chrome and Firefox.

Clearing Browser DNS Cache in Chrome

  • Open the Chrome browser and enter chrome://net-internals/#dns in the browser’s address bar.

how to Clear Chrome DNS Cache

  • Hit the “ Clear host cache ” button.
  • To apply your changes, restart the Chrome browser.

Clearing Browser DNS Cache in Firefox

  • Launch the Firefox browser, and in the address bar, enter about:networking#dns .

how to Clear Firefox DNS Cache

  • Click on the “ Clear host cache ” button.
  • You must restart the Firefox browser for the changes to take effect.

7. Reset Chrome Flags

Chrome Flags are a hidden and experimental feature in the browser that allows users to enable or disable settings and features that are not typically accessible. These features are usually provided for reasons such as performance testing, experimenting with new features, finding and fixing issues, or improving efficiency in the browser. If Chrome Flags have incorrect settings, it can block access to a specific website. Therefore, resetting Chrome Flags can be helpful in resolving the DNS_PROBE_FINISHED_NXDOMAIN error. Follow the steps below for this purpose:

  • Open the Chrome browser and go to the “ chrome://flags ” address to review Chrome flags and their status.
  • Click the “ Reset all ” button, or you can individually review the status of each flag and modify them if necessary.

how to Reset Chrome Flags

  • Restart the Chrome browser to apply your changes.

8. Disable Firewall

Firewalls block access to malicious websites to enhance system security. Incorrect firewall configuration can prevent access to specific websites and result in displaying the DNS_PROBE_FINISHED_NXDOMAIN error. Therefore, you should review the firewall settings and temporarily disable the firewall if needed.

Disabling the firewall can vary based on the Linux distribution and the firewall tool in use (e.g., iptables, UFW, firewalld). Here are a few common methods to temporarily disable the firewall in popular Linux distributions:

Disabling iptables in Linux (for older distributions)

If you are using iptables on your Linux system, temporarily stop the iptables service to disable the firewall. To do this, run the following command as root or with sudo:

Disabling UFW in Linux (for Debian/Ubuntu-based distributions)

If the UFW firewall is enabled on your Linux system, disable it by running the following command:

Disabling firewalld in Linux (for CentOS/Fedora-based distributions)

If you use firewalld, you must temporarily stop the firewalld service to disable it. For this purpose, use the following command:

We provided a comprehensive guide to disable the Windows firewall temporarily, but here we will briefly mention the steps. The steps to disable the firewall in Windows are as follows:

Navigate to Start menu > Windows security > Firewall & network protection > Select the active network profile > Turn the Microsoft Defender Firewall off.

After disabling the firewall, restart your system and check access to your desired website. If the error disappeared after disabling the firewall, the issue was with the firewall. However, if you still encounter the DNS error, the problem may not be with the firewall. In that case, re-enable the firewall, as disabling the firewall makes your system vulnerable to security threats and risks.

9. Disable VPN and Antivirus

Using antivirus and VPN is essential for security and data protection. Using both Simultaneously puts your system at a lower risk and helps preserve your data and privacy. However, they can block access to certain websites, leading to DNS errors. Temporarily disabling your antivirus and VPN allows you to check if the DNS-related issues are caused by them or for other reasons. You can roll back the changes if not needed.

So, shut down the VPN and try to connect to your desired website. Additionally, if you are using an antivirus, temporarily pause or quit it and check the access to your desired website.

10. Use Another DNS Server

If none of the solutions resolve the DNS error, you can use reliable and fast DNS servers such as OpenDNS or Google DNS instead of your Internet service provider’s DNS servers to solve the problem.

Changing DNS servers to Google DNS or OpenDNS in Linux requires modifying the DNS configuration file or network settings. The following steps will guide you in changing the DNS servers:

  • Open /etc/resolv.conf file using a text editor in the terminal:
  • Add the OpenDNS servers to the file:
  • Alternatively, you can Add the Google DNS servers to the file by running the following command:
  • Save and close the file.

To change the DNS server address in Windows, follow these steps:

  • Navigate to Control Panel > Network and Sharing Center .
  • Select “ Change adapter settings ” from the left pane menu.

Changing DNS servers in windows

  • Right-click on the current connection and choose the “ Properties ” option.
  • Select “ Internet Protocol Version 4 (TCP/IPv4) ” or “ Internet Protocol Version 6 (TCP/IPv6) ” and click the “ Properties ” button.

Changing DNS servers to fix DNS_PROBE_FINISHED_NXDOMAIN error

Check the “ Use the following DNS server addresses ” option and enter the following numbers:

For Google DNS :

Preferred DNS server:8.8.8.8

Alternate DNS server: 8.8.4.4

For Open DNS :

Preferred DNS server: 2001:4860:4860::8888

Alternate DNS server: 2001:4860:4860::8844

When you’re finished, click OK to save your modifications.

In general, the DNS_PROBE_FINISHED_NXDOMAIN error is nothing to be overly concerned about and can be resolved with one of the methods provided in this article. In addition to the methods presented in this article, properly checking the domain name or domain registration, restarting the router, rebooting the internet connection, temporarily turning off your CDN, checking the network connection, and restarting the DNS Client Service are common and effective methods that play a role in resolving the DNS_PROBE_FINISHED_NXDOMAIN error. If the problem persists after trying all the methods, it is advisable to contact your internet service provider or network administrator for assistance.

If you have tried any other effective method to resolve the DNS_PROBE_FINISHED_NXDOMAIN error, please suggest it in the comments section.

Related Article :  What is Debian OS

Leave a Reply Cancel reply

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

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

IMAGES

  1. How to Change IP Address in Linux

    how to change ip address in linux ubuntu

  2. How to change the IP address on Ubuntu

    how to change ip address in linux ubuntu

  3. Comment configurer une adresse IP statique sur Ubuntu 20.04

    how to change ip address in linux ubuntu

  4. How to change the IP address on Ubuntu

    how to change ip address in linux ubuntu

  5. Configuring static and dynamic IP Addresses in Ubuntu using Netplan

    how to change ip address in linux ubuntu

  6. How to change the IP address on Ubuntu

    how to change ip address in linux ubuntu

VIDEO

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

  2. How to Set A Static IP Address on Linux

  3. How to change ip address automatically on Linux

  4. Steps to Assign static IP Linux machine

  5. Configuring IP address on an Ubuntu Server

  6. How To Change DNS (Ubuntu 14)

COMMENTS

  1. How to Set a Static IP Address in Ubuntu

    Set a Static IP in Ubuntu with the GUI. 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.

  2. How to Configure Static IP Address on Ubuntu 20.04

    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.

  3. How to Change IP Address in Linux

    The ip command is available on most Linux distributions. For setting an IP address, use it like this: ip addr add [ip_address] dev [interface] For example, add an IP address to the eth1 interface as: sudo ip addr add 192.168.56.21/24 dev eth1. You now have two IP addresses: one from the old configuration and one from the new command:

  4. Change IP address on Ubuntu Server

    You have two options when configuring the IP address on your Ubuntu Server, and that is either a static IP address or DHCP. A static IP address allows you to manually select your IP address by configuring it on the Linux system, whereas DHCP relies on the router or DHCP server to lease you an IP address - either a reserved one or the next available one that is currently free, depending on ...

  5. Setting a Static IP in Ubuntu

    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. Manually setting a static IP using Ubuntu Desktop. Verify by using the command ip a.

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

  7. Netplan static IP on Ubuntu configuration

    Click on top right network icon and select settings corresponding to the network interface you wish to assign with the static IP address. Select wired or Wifi network settings. Next, click on the gear box icon next to your network connection you wish to configure. This could be wired or wireless connection.

  8. Ubuntu Change IP

    Ubuntu Linux Change IP Using Network Administration GUI Tool. The Network Administration Tool allows you to specify the way your system connects to other computers and to internet. ... To change IP address select Wired or wireless connection and click on properties button: ...

  9. How To Change IP Address on Linux

    To change your IP address on Linux, use the "ifconfig" command followed by the name of your network interface and the new IP address to be changed on your computer. ... (part of the sudo group on Debian/Ubuntu or wheel on CentOS/RedHat) For example, given the IP addresses used in the previous sections, if we want to change our IP address ...

  10. Ubuntu Static IP configuration

    Open network settings Ubuntu Desktop. Click on the settings icon to start IP address configuration. Start network configuration to set static IP address. Select IPv4 tab. Static IPv4 IP address Ubuntu Desktop. Select manual and enter your desired IP address, netmask, gateway and DNS settings. Once ready click Apply button.

  11. change ip address in Ubuntu Linux in 3 ways

    To do this, open up the Network Manager by clicking on the icon in your taskbar or searching for it in Dash. Once you're in the Network Manager, select your network connection and click "Edit". You should then see an option to change your IP address. Enter the new one and click "Apply" to save the changes.

  12. How to Configure Static IP Address on Ubuntu 18.04

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

  13. Manual Network Configuration in Linux and How to Set a Static IP Address

    On the other hand, a static IP ensures we always assign the same address. Of course, this comes with its own problems: manual settings might not comply with a given environment; might have to change configuration depending on the network; can lead to IP address conflicts, especially on smaller networks

  14. 3 Ways to change ip address in Linux

    Open the terminal application. List the current IP addresses for all network interfaces with command ifconfig -a. Take the network interface down with command: ifconfig <interface> down. Change the IP address with command ifconfig <interface> <ip address> <netmask>. Press Enter to run the command.

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

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

  16. Set static IP in Ubuntu using Command Line

    Step 2: See current IP address. Now that you know which interface needs to be addressed, let us edit a file. Before I change my IP address/set a static one, let us first see what my current IP address is. $ hostname -I 192.168.122.69. Nice! But let's change it to '192.168.122.128' for demonstration purposes. Step 3: See the gateway

  17. How To Change IP Address On Ubuntu

    The easiest way to change your IP address on Ubuntu is via the NetworkManager GUI. Open the Settings app and switch to the Network (wired) or Wi-Fi tabs depending on which connection you want to change the IP address for. Click on the Settings cog next to the connection.

  18. Configuring networks

    To configure a default gateway, you can use the ip command in the following manner. Modify the default gateway address to match your network requirements. sudo ip route add default via 10.102.66.1. You can also use the ip command to verify your default gateway configuration, as follows: ip route show.

  19. Setting a Static IP Address in Ubuntu 24.04 via the Command Line

    This command activates the new network configuration. If there are no errors, your system will start using the static IP address you've configured. Verify the New Static IP Address: To confirm that the static IP address has been successfully assigned to your network interface, use the ip a command. $ ip a

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

    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.. Visit Stack Exchange

  21. How to permanently change the IP address of Ubuntu with CLI only?

    Two (of many ways) to do it, say you want the new IP to be 192.168.80.10 with netmask 255.255.255 and your interface is eth0. $ sudo ifconfig eth0 192.168.80.10 netmask 255.255.255.. or, with the newer ip command, you remove the old address and add the new one: $ sudo ip address del old.ip.address/netmask dev eth0.

  22. How to Configure Static IP Address on Ubuntu 24.04 (Desktop)

    When you want a persistent IP address on your Ubuntu 24.04 desktop, then you must a configure a static IP address. Whenever we install Ubuntu then DHCP is enabled by default, and it will try to fetch the IP address from DHCP server if it is available over the network. In Ubuntu Desktop 24.04, there are two ways to configure static IP address:

  23. How to change the hostname on Ubuntu

    Hit Ctrl+X followed by Y to save and exit the hosts file. (Optional) If you're running Ubuntu as a cloud instance with the help of the cloud-init utility, you'll need to modify a third config file ...

  24. Change the hostname of your AL2 instance

    Change the system hostname. If you have a public DNS name registered for the IP address of your instance (such as webserver.mydomain.com), you can set the system hostname so your instance identifies itself as a part of that domain.This also changes the shell prompt so that it displays the first portion of this name instead of the hostname supplied by AWS (for example, ip-12-34-56-78).

  25. Fix DNS_PROBE_FINISHED_NXDOMAIN in Linux & Windows

    You can change the address provided by DHCP with Release and Renew IP Address. For Linux: To Release and Renew IP Address in Linux, follow these steps in order: Open the Linux terminal by pressing the Ctrl+Alt+T shortcut keys. To release the current IP, use the following command: sudo dhclient -r. Output: Killed old client process. After making ...

  26. How to Create a Portable PC on a USB Drive

    View on Facebook Page (Opens in a new tab) View our Twitter Page (Opens in a new tab) View our Instagram Page (Opens in a new tab) View our Youtube Page (Opens in a new tab)

  27. How to configure static IP address on Ubuntu 20.04 ...

    The objective of this guide is to configure static IP address on Ubuntu 20.04 Focal Fossa Linux. In this tutorial you will learn: How to set static IP address on Ubuntu Desktop and Server; How to set static gateway and DNS server

  28. phpMyAdmin Installation on Ubuntu 24.04

    How to Install LAMP Stack (Linux, Apache, MariaDB and PHP) on Ubuntu 24.04; How to Install Flarum Next Generation Forum on Ubuntu 24.04; Build a Monitoring System with Grafana and Prometheus on Debian 12; VirtualBox 2: How To Pass Through USB Devices To Guests On An Ubuntu 8.10 Host; Linux Basics - Set a Static IP on Ubuntu

  29. How can I close some specific port on Linux?

    Step 1: Open up cmd.exe (note: you may need to run it as an administrator, but this isn't always necessary), then run the below command:. netstat -ano | findstr :<PORT> (Replace <PORT> with the port number you want, but keep the colon). The area circled in red shows the PID (process identifier). Locate the PID of the process that's using the port you want.