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.

RaspberryTips

How to Set Static IP Address on Ubuntu Server (Step-by-step)

Most networks automatically assign IP addresses, which is quite convenient for desktop computers. But for a server, it’s recommended to configure it with a static IP, often outside the DHCP range, so it’s always available at the same address. How do you configure this without a GUI ? Let’s find out.

On Ubuntu Server, the network configuration is managed by the netplan utility, with the configuration file located in /etc/netplan. It’s possible to set a static IP by editing this file.

Before making any changes, make sure you understand your network configuration and find a free IP address for your server (I will explain how to do this). Only then you can edit the netplan configuration file to assign a static IP address to your server.

Prerequisites: Understand the network configuration

I guess if you’re installing a server on your network, you already know your network pretty well. However, I want to make sure what we are doing is clear for everyone, so I’ll take a few minutes to explain what you need before changing anything.

Feel free to skip this section if you already know the exact network configuration you want to apply to your server.

Get your current IP configuration

On Ubuntu Server, you can use the following command to get your current IP address: ip a

how to setup a static ip on ubuntu server

You’ll get a list of all the network interfaces, with their names, IP addresses and subnet mask.

In my example, I have:

  • Interface name : eth0
  • IP address : 192.168.0.33/24 (assigned by the DHCP)

To find the router or default gateway on your network, you can then use: ip r

how to setup a static ip on ubuntu server

I now have a better sense of my network configuration.

how to setup a static ip on ubuntu server

If you’re new to the Linux command line, this article will give you the most important Linux commands to know, plus a free downloadable cheat sheet to keep handy.

(Optional) Find the DHCP range

If you have a DHCP server enabled on the network, it’s a good idea to access the router configuration and check the current DHCP range. If possible, you don’t want to set a static IP inside that range.

All router interfaces are different, so I won’t explain everything in detail here, but you should easily find a section with the start and end IP address for the DHCP range. Try to pick an IP on the same subnet but outside that range for your server.

In my example, the router is 192.168.0.254, the DHCP range is from 192.168.0.10 to 192.168.0.50. I can safely set my server to 192.168.0.150 if it’s not already used by another server.

Note : You can use a network scanner if you don’t have a list of all IP addresses already used on your network (most routers will list them). You can use the ‘nmap’ command on Linux or Advanced IP Scanner from a Windows computer on the same network.

Set the static IP to your Ubuntu Server

At this point, you must know which IP address you’ll use for your server, the network gateway, and probably the DNS server if one is required (on small networks, it’s often the same as the gateway).

In my case, I’ll use the following configuration:

  • IP address : 192.168.0.150
  • Gateway : 192.168.0.254
  • DNS : 8.8.8.8

Make sure to change these values with yours in the following sections.

Open the network configuration file

As mentioned in the introduction, the network configuration file on a fresh Ubuntu Server installation is now located under /etc/netplan .

I think the file name can be slightly different depending on your setup, so it’s probably best to go inside this folder and check what’s available. You can do it with: cd /etc/netplan ls -l

how to setup a static ip on ubuntu server

In my case, the file name is “50-cloud-init.yaml” because I’m testing this on a virtual machine, but adapt the following commands to yours if it’s different.

You can see the current configuration with: sudo cat 50-cloud-init.yaml

how to setup a static ip on ubuntu server

And it’s probably a good idea to create a backup of this file just in case something goes wrong. sudo cp 50-cloud-init.yaml ~/50-cloud-init.yaml.default

You can now open the file in edit mode with: sudo nano 50-cloud-init.yaml

Set your static IP address

To set the static IP address, we’ll slightly edit this file to add the IP address, gateway and DNS server information.

Once the file opens with Nano, or your favorite text editor, make the changes to make it look more like this:

Warning : this file is in YAML format. It’s essential to keep the file structure and indentation, or it won’t work. Make sure only to use spaces (no TAB).

Save your changes and exit Nano (CTRL+X).

You can test your configuration file without rebooting with: sudo netplan try

If it works, your IP address will change directly. But if there is any issue, it will give you the error message, without losing the connection (as with the next command).

Apply the changes

To apply the new network configuration persistently, you must run this command: sudo netplan apply

After doing this, your new network configuration will be applied automatically on boot, and you should always get the same IP address, gateway and DNS server used on this server.

Verify the new configuration

You can verify the new configuration with the same commands used at the beginning of the article: ip a ip r

In my example, I now have:

how to setup a static ip on ubuntu server

Related questions

How to set up a secondary dns server in netplan.

In the Netplan configuration, a secondary DNS server can be set by appending the server’s IP address to the addresses list under the nameservers section.

I recommend always having a backup DNS server in your configuration to make sure everything keeps working even if the main DNS server is unreachable.

To add this in Netplan, you just need to edit your YAML file and include the second DNS server’s IP address right after your primary one, separated by a comma.

Is it better to set a static IP on the router instead?

Setting a static IP on the router, often referred to as DHCP reservation, is considered more manageable and flexible compared to configuring a static IP on individual devices.

If you can, I recommend setting this static IP directly on the router, especially if you’re managing multiple devices. This way, your router automatically assigns the same IP to your server each time it connects.

It’s easier to configure, you keep track of all your servers in one place, and you avoid conflicts. The only requirement is that you have a router that handles this properly (and that the Ubuntu server you’re setting up now is not your DHCP server).

Can we use “nmcli” instead of editing the Netplan configuration manually?

nmcli, a command-line tool for Network Manager, presents an alternative to Netplan for network configuration on Ubuntu, offering a more interactive and user-friendly approach.

If you’re not a fan of editing YAML files for network settings, nmcli is your friend. It’s straightforward and interactive, making network configuration less intimidating. You can view, modify, and manage all your network connections just with simple commands.

Just keep in mind that on Ubuntu Server, nmcli is not included by default as it is part of the Network Manager package, that must be installed manually. This installation introduces a different network management tool that may override existing network configurations managed by Netplan.

To install NetworkManager, you just need to run: sudo apt install network-manager After installation, you can start using nmcli to change your network configuration in a more user-friendly way: sudo nmcli

How do you restore the original network configuration?

If you followed this tutorial, but something didn’t work as expected, or you want to get back the DHCP configuration (maybe to try to configure everything from the router instead), you can restore the backup configuration file we created.

  • Restore the original file with: sudo cp ~/50-cloud-init.yaml.default /etc/netplan/50-cloud-init.yaml Make sure to change the file name if it was something else on your system.
  • Apply the configuration with: sudo netplan apply

That’s it, you are now back to the default configuration, with the DHCP assigned IP address.

Want to chat with other Raspberry Pi enthusiasts? Join the community , share your current projects and ask for help directly in the forums.

  • Master Linux Commands (eBook)
  • The 5 fastest ways to find a file on Linux
  • Snap vs APT: what's the difference?

Additional Resources

Overwhelmed with Linux commands? My e-book, “Master Linux Commands”, is your essential guide to mastering the terminal. Get practical tips, real-world examples, and a bonus cheat sheet to keep by your side . Grab your copy now . VIP Community If you just want to hang out with me and other Linux fans, you can also join the community. I share exclusive tutorials and behind-the-scenes content there. Premium members can also visit the website without ads. More details here. Need help building something with Python? Python is a great language to get started with programming on any Linux computer. Learn the essentials, step-by-step, without losing time understanding useless concepts. Get the e-book now.

Sharing is caring!

' src=

I'm the lead author and owner of RaspberryTips.com. My goal is to help you with your Raspberry Pi problems using detailed guides and tutorials. In real life, I'm a Linux system administrator with web developer experience.

Similar Posts

Do You Need an Antivirus on Ubuntu? (And how to install it)

Do You Need an Antivirus on Ubuntu? (And how to install it)

For Windows users, installing (or enabling) an antivirus on their system has become one of the first steps over the years. But for a Linux system, like Ubuntu, the choice is not as clear. Is it really necessary? In this article, I will answer your questions and give you a few tips depending on your…

Debian: How To Enable The Root User (Login & SSH)

Debian: How To Enable The Root User (Login & SSH)

For a long time, root was the default user on Linux, but it’s now disabled on most distributions. If like me, you were used to it, this article will answer your questions and guide you with the new best practice. I’ll also show you some workarounds if you really need “root”. On Debian, using “sudo”…

How To Safely Install Bitwarden On Linux (Debian/Ubuntu)

How To Safely Install Bitwarden On Linux (Debian/Ubuntu)

Bitwarden is an open-source password manager. Like other alternatives, you can use it for free by hosting your passwords on their servers, but you can also self-host it on your own server, running at home or on your company network. That’s the project we’ll try throughout this article. Bitwarden can be installed on a Linux…

Getting Started With Wireshark On Ubuntu

Getting Started With Wireshark On Ubuntu

Wireshark is a free and open-source tool to capture and analyze network traffic. Basically, it will intercept network packets and display their content in a nice interface, so you can analyze them. It’s available on most Linux distributions, including Ubuntu. I will show you how to install it on your computer, and share interesting features…

How to Increase Font Size in the Linux Terminal (+ Bonus tips)

How to Increase Font Size in the Linux Terminal (+ Bonus tips)

Using the Linux terminal is already not the best user experience and, in addition, we often keep the default settings when using it. Many things can be configured to improve readability even when you don’t have a graphical user interface ( GUI ). In this post, I’ll share different tips to do this. When a graphical interface…

How to Install Pi-Hole on Ubuntu (Beginner’s Guide)

How to Install Pi-Hole on Ubuntu (Beginner’s Guide)

Ads are all over the place on the Internet. Most people develop a sixth sense to ignore them, use a browser extension like AdBlock to hide some of them, or block everything on their whole network by installing Pi-Hole on Ubuntu. How do you do this? I will explain my setup in this article. Pi-Hole…

Level Up Your Linux Skills: Free PDF with Must-Know Linux Commands!

Learn Ubuntu

Static IP in Ubuntu

Set static IP in Ubuntu using Terminal

Pratham Patel

Table of Contents

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.

Please enable JavaScript

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 setup a static ip on ubuntu server

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 setup a static ip on ubuntu server

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.

You might also like

How to Open and Edit bashrc file in Ubuntu

How to Open and Edit bashrc file in Ubuntu

Sagar Sharma

How to Quit the Terminal in Ubuntu

How to Find SSH Keys in Ubuntu

How to Find SSH Keys in Ubuntu

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

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.

Log in or Sign up

Linux basics - set a static ip on ubuntu, on this page, configure a static ip address with netplan on ubuntu, configure a dhcp address with netplan, more netplan config options, step 1: configure the network interface, step 2: configure the dns servers, step 3: restart networking, configure the hostname.

This tutorial explains how to set up a static IP address on an Ubuntu system from the command line. It covers network configuration for all current versions of Ubuntu and includes instructions for configuring a static IP address, setting the hostname, and configuring name resolution.

Network configuration on Ubuntu 22.04, Ubuntu 20.04, and Ubuntu 18.04

The network configuration in Ubuntu is made with a tool called netplan. It replaced the traditional /etc/network/interfaces file.

Here are the steps to configure a static IP address with Netplan. The Netplan configuration files are in the directory /etc/netplan/ . The default configuration file is  /etc/netplan/01-netcfg.yaml .

Open the network config file with an editor. The netplan configuration filename differs depending on the Ubuntu version.

Ubuntu 22.04 and Ubuntu 20.04 :

Ubuntu 18.04 :

The configuration syntax is in Python programming language (.yaml format), so the indentation of the lines is important!

The content of the file is the same on Ubuntu 22.04 - 18.04.

Here is an example of a static IPv4 address 192.168.1.100 on the first network interface ens33 and gateway IP 192.168.1.1 . The server will use the free Google DNS servers 8.8.8.8 and 8.8.4.4 to for name resolving.

Or, as Screenshot from an Ubuntu server:

Ubuntu 22.04 Network Configuration File

An IPv6 address can be added in the addresses line, separated by a comma. Example:

You must wrap the IPv6 address into single quotes. You will get a syntax error otherwise.

To apply the changes, run the following:

Or use it with the --debug switch to get some useful output if parsing of the netplan config file was successful.

Here is the configuration to get the network configuration for IPv4 and IPv6 from a DHCP server.

To apply the changes, run:

Netplan is a complex new configuration system configuring network cards, virtual devices, VLANs and bridges in Ubuntu 18.04. See the man page for more examples and an in-depth explanation of the syntax.

Network configuration on  Ubuntu 12.04 - 17.04 (incl. Ubuntu 16.04 LTS)

In this step, you will manually configure your network interface by editing the following files using your preferred text editor(nano gedit vi). For this example, I'm using the "nano" editor. You can edit the appropriate file by entering the following command into the terminal:

You can copy and paste directly from this line.

Enter your root password, once your preferred editor opens the file you can see this on older Ubuntu versions:

Ubuntu Systems with systemd (like Ubuntu 16.04 and newer), the network interface is named ens33 instead of eth0 now and the word 'dynamic' has been replaced with 'dhcp'.

A configuration where the IP address get's assigned automatically by DHCP will look like this:

Statically configured network cards will have a section like this on older Ubuntu versions:

Here is an example for an older Ubuntu Release:

And here an example for Ubuntu 16.04 and newer:

And here the complete network configuration file from an Ubuntu 16.04 system.

Interfaces configuration file

If you use "nano" editor to edit the configuration file, type Ctrl+x to save changes.

Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) ?

<---Type "y"

File Name to Write: interfaces

<---ENTER

Changes in /etc/resolv.conf are required only on Systems with Ubuntu < 14.04, for newer Ubuntu versions the nameservers get configured in the /etc/network/interfaces file or the netplan config file.

a) Ubuntu 20.04

Open the netplan configuration file with an Editor. I will use the nano editor in this example:

I've marked the DNS server IP addresses bold:

b) Ubuntu 18.04

Open the netplan configuration file with the nano editor:

c) Ubuntu versions 14.04 and 16.04

Open the /etc/network/interfaces file again and add a line dns-nameservers 8.8.8.8 right after the gateway line.

The nameservers 8.8.8.8 and 8.8.4.4 are provided by Google for public use, so you can use them in your network configuration.

If you use "nano" editor, type Ctrl+x to save changes.

d) Ubuntu versions < 14.04

In this step, you will manually configure your dns configuration file.

Once your editor opens the file you want to enter the following information...

File Name to Write: resolv.conf

Here is an example:

Manually restart your network interface with the new settings.

For Ubuntu 20.04 and 18.04 , use the netplan command to apply changes and restart the network. The command is:

For Ubuntu versions 14.04 and 16.04 we use systemctl instead:

At this point you can check if the settings are correct:

If everything is correct you will get this result.

For Ubuntu < 14.04 use the networking init script:

This should return a result that looks like the following:

The hostname of an Ubuntu Server or Desktop is being configured in the files /etc/hostname and /etc/hosts . The /etc/hostname file sets the actual system hostname while /etc/hosts is used for the local name resolution.

In this example, I will change the hostname of my system to obelix.example.com.

First, edit the /etc/hostname file

The hostname file contains the local part of the hostname only. The local part here is "obelix". Change the content of the /etc/hostname file to:

and save the file. The hostname file as it looks in nano after editing:

Configure Ubuntu Hostname

Then open the /etc/hosts file with an editor:

and change the line that starts with the IP address of the system like this:

Here a screenshot of the /etc/hosts file.

Ubuntu hosts file

The format is like this:

[IP Addesss] [full hostname incl. domain] [local part of the hostname]

Finally, restart the system to apply the hostname change.

how to setup a static ip on ubuntu server

36 Comment(s)

  • Log in with Facebook
  • Log in with Twitter
  • Log in with Google
  • No, create an account now.
  • Yes, my password is:
  • Forgot your password?

This feature is only available to subscribers. Get your subscription here .

How to Configure Static IP Address on Ubuntu 22.04 LTS and 22.10

Switching from dynamic IP allocation to static IP addresses is easy on Ubuntu 22.04 "Jammy Jellyfish" and 22.10.

The IP addresses of most devices today are generated by Dynamic Host Configuration Protocol (DHCP) servers. A DHCP server assigns a dynamic IP address to your device when it's connected to a network. Thus, you have the chance to change this IP address from time to time.

On the other hand, a static IP refers to a fixed, immutable address, different from dynamic IPs. You can set static IP settings for Ubuntu 22.04 LTS and 22.10 in three different ways. Here's how to get started.

Understanding IP Configuration in Ubuntu

Ubuntu's progression in network management has made configuring settings like the static IP more user-friendly. The feature to set a static IP in Ubuntu 22.04, in particular, has advantages in terms of network efficiency and stability.

Unlike dynamic IPs, which might vary over sessions, a static IP in Ubuntu remains consistent. This is especially advantageous for servers where consistent address recognition is paramount. For these servers, static IP configurations can become a necessity.

While the graphical interface offers a more intuitive way to handle IP configurations, using the static IP command line can offer more precision. For users who want granular control over their network configurations, command-line methods are a preferred choice. By mastering this method, users can ensure optimal Ubuntu IP configuration for their needs.

However, the benefits of a static IP in Ubuntu, especially in the 22.04 version, come with responsibilities. Ensuring that these IPs are correctly set up is crucial, as misconfigurations can lead to network vulnerabilities.

So follow the steps below to configure a static IP address on your Ubuntu machine correctly.

Set a Static IP on Ubuntu With the nmcli Command

It's pretty easy to configure Ubuntu 22.04 static IP settings using the nmcli command . nmcli is a text-based utility used to check the status of the wired connections you are using on your device.

With this command, you can access additional networking information such as your connection status, the name of your host device, and general permissions in your network configuration. If you're aiming to set a static IP on an Ubuntu server, this command proves invaluable.

You can get information about your connection with:

The output of this command will be as follows:

Create a static link with the command given below. Then, manually configure the enp0s3 and ipv4 settings with the appropriate parameters in the nmcli command:

If you use the nmcli connection show command again, you can see that the static link has been added.

nmcli-add-static-command-show

After this process, add the static connection you created to the DNS IP:

Now use the command below to activate the connection:

If the output displays "connection successfully activated," you've successfully set up a static IP address on your machine.

You can consider using static IP addresses to avoid connection problems caused by dynamic IP addresses. A static IP address allows you to have a fixed identity and location when connected to the internet.

You can verify the static IP you want to assign to your device by running:

ip-route-command-output

Using netplan for Static IP Settings on Ubuntu

Just like nmcli, another command you can use for setting a static IP on Ubuntu is netplan. You can easily make Ubuntu static IP settings using the netplan command in 22.04 LTS and 22.10 versions. To do this, follow the steps below.

First, find out the name of your network interface using:

sudo-ip-a-command-output

What you see here is your network interface name. This name may be different on each device.

Now, create a file named 01-netcfg.yaml in the /etc/netplan folder. Edit it with your favorite text editor.

Add the following lines to the file:

As you can see, you have disabled the DHCP IP setting with the dhcp4: no statement. You've then added the IP address and DNS settings assigned by Google.

After saving this file, run the following to apply the changes:

Configure Static IP Settings on Ubuntu Graphically

The graphical network interface in Ubuntu 22.04 is quite useful if you don't want to use the command line. So much so that you can easily set the Ubuntu static IP address using this interface.

To do this, click on the Network icon in the upper right corner of your desktop. Then, select Wired Settings from the drop-down menu. Click on the Gear icon to open the settings window.

settings-screen-settings-1

Then, switch to the IPv4 tab in the window that opens.

ipv4-settings-with-gui

As you can see, DHCP is enabled by default. Change the IPv4 Method to Manual as you want to use a static IP instead of a dynamic one. Next, change your address, netmask, and gateway settings. Finally, modify your DNS setting and click the Apply button.

ipv4-settings-apply-button

You must restart this wired connection for all these actions to take effect. To do this, simply toggle the switch next to the network name on and then off.

gui-settings-apply

Why Should You Use Static IP Addresses on Ubuntu?

You've now understood how to configure a static IP in Ubuntu, especially in the "Jammy Jellyfish" 22.04 LTS version and 22.10, using both graphical and command-line methods with nmcli and netplan.

Due to insufficient IP addresses, some service providers may assign the same address to two different users. In this case, connection problems can occur. Using static IP addresses instead does not cause such problems as it is user-specific, but beware as someone can misuse your IP address in several ways.

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

logo

How to Configure Static IP Address on Ubuntu Server 22.04

In the default network configuration of Ubuntu, dynamic IP addressing is used, which means that the network management daemon in Ubuntu searches for and configures an IP address for the server using the IP address assigned by a DHCP server on the network to which it is connected. When you install Ubuntu server, the network setup is set to static IP addressing by default, which is not ideal. In this chapter, you will learn how to configure a network interface to have a static IP address assigned to it.

Step 1 : Use the following command to get a list of accessible Ethernet interfaces.

how to setup a static ip on ubuntu server

Step 2 : Locate the following lines in /etc/netplan/00-installer-config.yaml:

how to setup a static ip on ubuntu server

Step 3 : To the preceding lines, add an IP address, a net mask, and a default gateway (replace the samples with the appropriate values) as follows:

how to setup a static ip on ubuntu server

Step 4 : If you want to make these modifications permanent, use the following command:

how to setup a static ip on ubuntu server

Step 5 : To test the network connection, try pinging a distant host:

how to setup a static ip on ubuntu server

Recommended

how to setup a static ip on ubuntu server

How to Configure SELinux on CentOS Stream 9

2 months ago

how to setup a static ip on ubuntu server

How To Install FirewallD on CentOS Stream 9

how to setup a static ip on ubuntu server

How to Update CentOS Stream 9

how to setup a static ip on ubuntu server

CentOS Stream 9 Guides

how to setup a static ip on ubuntu server

How to Install CentOS Stream 9

how to setup a static ip on ubuntu server

How to Create Bootable USB installer for CentOS Stream 9

how to setup a static ip on ubuntu server

How to Install RabbitMQ on on Rocky Linux 9

how to setup a static ip on ubuntu server

How to Install and Configure Jenkins on Rocky Linux 9

how to setup a static ip on ubuntu server

How To Install Memcached on Rocky Linux 9

how to setup a static ip on ubuntu server

How to Install and Configure VNC Server on Rocky Linux 9

how to setup a static ip on ubuntu server

How to Install and Use rsync on Rocky Linux 9

how to setup a static ip on ubuntu server

How to Install PHP 8.3 on Rocky Linux 9

how to setup a static ip on ubuntu server

How To Install and Configure Postfix on Rocky Linux 9

how to setup a static ip on ubuntu server

How to Configure Static IP Address on Rocky Linux 9

how to setup a static ip on ubuntu server

How to Manage Network Interfaces on Rocky Linux 9

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 setup a static IP on Ubuntu Server 18.04

I've seen some people saying the file to set static ip is still /etc/network/interfaces

And I've seen other people saying that in 18.04 it's now on /etc/netplan (which people seem unhappy about)

I've tried putting this:

In my /etc/netplan/50-cloud-init.yaml and doing sudo netplan apply but that just kills the servers connection to the internet.

Pablo Bianchi's user avatar

  • 1 Is it a desktop or a server? –  user68186 Apr 29, 2018 at 5:10
  • 1 Is this a fresh 18.04 install or upgrade from another version? –  WinEunuuchs2Unix Apr 29, 2018 at 5:16
  • Sorry I should've said this in the text, its a fresh install of 18.04 server. –  final20 Apr 29, 2018 at 5:25
  • The most simple solution for me was, to specify a static IPv4 address right during installation (together with subnet, gateway, etc.). Simply fill out some wizard fields, no messing with configuration files. –  Uwe Keim Oct 9, 2018 at 10:01
  • You can also do this on routers. Steps are self-explanatory in the router config. –  EODCraft Staff Jan 12, 2019 at 10:25

11 Answers 11

All the answers telling you to directly edit /etc/netplan/50-cloud-init.yaml are wrong since CloudInit is used and will generate that file. In Ubuntu 18.04.2 it is clearly written inside the file :

So you should not edit that file but the one under /etc/cloud/cloud.cfg.d/ if you still want to use CloudInit.

Another way is to completely disable CloudInit first by creating an empty file /etc/cloud/cloud-init.disabled (see https://cloudinit.readthedocs.io/en/latest/topics/boot.html ) and then the other answers are OK. Under Ubuntu 18.04.2 I had to use dpkg-reconfigure cloud-init to let it take into account the file /etc/cloud/cloud-init.disabled . I think this is a little bit weird.

I suggest you to rename the file (not the right name since 50-cloud-init.yaml let us think it still uses CloudInit).

Then you may end up with a file name /etc/netplan/01-netcfg.yaml which contains the configuration below. Note the use of the networkd renderer instead of NetworkManager because the configuration is on a server.

Ludovic Kuty's user avatar

  • 4 It works great. This should be the best answer. 50-cloud-init.yaml as stated shouldn't be modified. –  Relic Jun 26, 2019 at 13:11
  • 3 If still using CloudInit, you need to do a sudo cloud-init clean -r to get the change to take, as per veperr's answer (at least for me on Ubuntu Server 18.04.3). –  Stuart Rossiter Aug 8, 2019 at 11:59
  • 1 ...plus the renderer line is no longer valid it seems (and is missing in the base version of the file that you edit). –  Stuart Rossiter Aug 27, 2019 at 10:26
  • Simply adding a custom file under /etc/netplan/##-*.yaml works as well. Such as: "/etc/netplan/99-custom-network.yaml". This also follows the netplan.io/examples instructions. In "conf.d" type config areas you should always opt for a custom/new file if possible instead of editing installed package files. It's why we have these "numbered file" areas. These default #'ed files can frequently get overwritten. And YES: If you have a "50-cloud-init.yaml", it should NOT be used. It is system generated as noted in comments. Why people keep posting this as an answer is anyone's guess? –  B. Shea Dec 13, 2021 at 15:59
  • 1 Yep. But, you can add it directly to /etc/netplan . Any new files under this area will persist through reboots. I gave you +1 for 1: saying not to edit cloud-init, and 2: Creating a new file in a numbered area (& not editing ANY preexisting/system ones). Note: You do not even necessarily need to disable anything so long as you are updating the same network interface. A higher numbered yaml will override all previous repeated directives (or should). So "50-" will be read in AFTER "01-". If you renamed your file "99-" you wouldn't have to disable "50-" - if that makes sense. See my answer –  B. Shea Dec 13, 2021 at 16:34

This is set a static IP instruction in Ubuntu-Server 18.04 and 20.04

Then replace your configuration, for example, the following lines:, apply changes:.

In case you run into some issues execute:

  • /24 is equivalent with 255.255.255.0
  • ens160 is your ethernet name, you can get it using $ ifconfig
  • Ubuntu 16.04 and 14.04 network-interface configuration have a different method.
  • The file is in YAML format : Use spaces, no tabs.

Benyamin Jafari's user avatar

  • not able to ping after assigning static IP address –  gjois Mar 3, 2019 at 14:55
  • OK....I'm able to ping after doing service networking restart –  gjois Mar 3, 2019 at 15:42
  • 7 I wouldn't do that since that file is generated by CloudInit –  Ludovic Kuty Mar 13, 2019 at 7:48
  • only works if your ethernet is "ens160", check your ethernet "ls /sys/class/net/" and replace "ens160" with it. –  sailfish009 Mar 17, 2020 at 3:40
  • @sailfish009 I mentioned it before in the NOTE section in my answer. –  Benyamin Jafari Mar 17, 2020 at 6:11

I've found another way using cloud-init.

  • Edit the file /etc/cloud/cloud.cfg.d/50-curtin-networking.cfg - the contents seem to be the same as they would be in /etc/netplan.

clean, reboot and re-initialize cloud-init with this command:

That's it! Your system will reboot, cloud-init will re-initialize and pickup the change in /etc/cloud/cloud.cfg.d/50-curtin-networking.cfg and apply them to /etc/netplan/50-cloud-init.yaml and all will be well. Verify with ifconfig .

zx485's user avatar

  • 1 2 things. -> 1. Better to create your own "99-myconfig.cfg" file under /etc/cloud/cloud.cfg.d/ so it's read in last and will overwrite any previous configs and will not be overwritten by possible system updates. 2. ifconfig is defunct . Use ip command now. For example ip addr will show same thing as ifconfig use to. –  B. Shea Dec 7, 2021 at 16:11

Ubuntu 18.04 uses now Netplan to configure the network interfaces, so the configuration must be done in the file /etc/netplan/50-cloud-init.yaml , the documentation advises not to mess anymore with the old file /etc/network/interfaces . I have used this configuration with my Ubuntu Server virtual machine and it works so far, just make sure the info is correct; the optional: true setting supposedly speeds up the booting time by not verifying if the interface is connected or not, this is default, also there is no need to declare values not used, for example DHCP, if they are absent they are taken as disabled, also the default renderer in Ubuntu Server is networkd so there is no need to declare it. Taking the information from your post, it should be like this:

Once you save the file, run sudo netplan --debug apply the debug flag will output more info and can help to detect any errors. Check the ethernet cable, if in virtual review the VM configuration. If using a WLAN I have read that it is a bit more tricky to setup but I haven't yet set up a machine connected to WiFi with this server version.

If you want more info about Netplan there is a website, it has some basic configuration examples.

https://netplan.io/

badger_8007's user avatar

  • 1 Wrong. DO NOT EDIT 50-cloud-init.yaml , or any existing system generated files! –  B. Shea Dec 13, 2021 at 16:40

Config file is in YAML format : Don't use TAB when configuring the file. It only works with SPACE .

HubbleT's user avatar

Writing a new answer as so many are just wrong.

Do not edit 50-cloud-init.yaml , 00-installer-config.yaml or ANY system generated files/package files.

From https://netplan.io/examples/ :

"To configure netplan, save configuration files under /etc/netplan/ with a .yaml extension (e.g. /etc/netplan/config.yaml) .."

The installer/ system did that. Now you need to override it.

Also consult man netplan-generate for the rules governing how the network configurations are read from /etc/netplan/*.yaml (and elsewhere).

To correctly update the netplan area to use a static IP over the default DHCP:

Edit/Create a new file (the prepended number+dash and .yaml extension are important):

sudo nano /etc/netplan/99-custom-network.yaml

Add your properly formatted YAML to this file. A static IP example:

(Note: My network device is ens160 - not eth0 - adjust as needed.) Save. Then do a sudo netplan apply . Make sure your network interface looks right and is working ( ip ad / ping ). Then do a reboot. Retest.

This follows the netplan.io instructions as well as the general rule of not editing any existing/installed files when possible. In /etc/netplan/ and similar conf.d/ type config areas you should always opt for a high numbered custom/new file (if possible) instead of editing any installed package files.

It's why they have numbered files in these configuration areas (in /etc/netplan/ and others). The higher the number on the file equates to when it is read in.

Therefore, something with "99-" prepended on it will generally be read in last and OVERRIDE anything that repeated before it. Therefore, if a network interface is set to DHCP in "00-installer-config.yaml", and/or "50-cloud.init.yaml", the settings for the same interface in a "99-*.yaml" file will override everything else read in previously.

Generally these installed YAML files will NOT get overwritten, but that isn't valid logic to not follow the conf.d "standard" of using custom files to override and avoid editing any installed files. It doesn't take any extra time. Drop a file in netplan. Done. So, there's no excuse as I have witnessed in comments of "well, it's worked so far..".

So, editing the default netplan *.yaml(s) will technically (usually) "work", but you should avoid using them when possible.

B. Shea's user avatar

Network configuration in 18.04 is managed via netplan and configured with cloud-init. To change your network configuration edit the 50-curtin-networking.cfg file in /etc/cloud/cloud.cfg.d/ . If this file does not exist then create it.

Find your interface name

Edit / create the cloud-init network configuration file

To set a static IP address, use the addresses key, which takes a list of (IPv4 or IPv6), addresses along with the subnet prefix length (e.g. /24). Gateway and DNS information can be provided as well:

You can find more configuration options at https://netplan.io/examples

Reload the cloud-init configuration. This will reboot your server.

Ryan's user avatar

This is the setting what make it work.

restart the server

change eth0 to your adapter, find out your adapter using ifconfig.

Digerate's user avatar

  • 1 Wrong. DO NOT EDIT 50-cloud-init.yaml, or any existing system generated files! –  B. Shea Dec 13, 2021 at 16:41

To find available ethernet interfaces use ip link show

Then edit the 50-cloud-init.yaml file using $sudo nano /etc/netplan/50-cloud-init.yaml

Add the configuration for available interfaces like eth0: and eth1:

Then use command $sudo netplan apply to apply the changes.

Anand Prakash Singh's user avatar

Then edit the 50-cloud-init.yaml file using $sudo vim /etc/netplan/50-cloud-init.yaml

$ sudo netplan apply

Community's user avatar

  • 1 I wouldn't do that since that file is generated by CloudInit. –  Ludovic Kuty Mar 13, 2019 at 7:47
  • 1 Why oh why is every guide to setting a static IP on 18.04 telling me to edit a yaml file that says it is a dynamically created file that will not persist? Another cruel joke from the Ubuntu developers that think it is ok to just break things by default... –  Bigtexun Mar 20, 2019 at 18:13
  • 1 Wrong. DO NOT EDIT 50-cloud-init.yaml, or any existing system generated files! –  B. Shea Dec 13, 2021 at 16:42
  • @B.Shea I have 20+ servers running for 4 years with regular upgrades and maintenance. Never once, 50-cloud-init.yaml has been reset or overwritten. For what I have noticed, cloud-init (as the name says) is run once, at server creation and then it won't be automatically reissued again. –  Dario Fumagalli Mar 2, 2022 at 3:34
  • 1 @DarioFumagalli Only 4 years? You're using broken logic: Just because nothing "broke" doesn't mean you are doing it the proper way. You should NEVER edit system installed config files if there is a way to avoid it. And there is clearly a way to avoid it in this case.. –  B. Shea Mar 2, 2022 at 13:07

This worked for me:

[172.23.4.2/24, ] is the additional thing I did on the yaml file.

Reference: https://serverspace.io/support/help/how-to-configure-static-ip-address-on-ubuntu-18-04/

BeastOfCaerbannog's user avatar

You must log in to answer this question.

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

  • The Overflow Blog
  • Down the rabbit hole in the Stack Exchange network
  • 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...
  • AI-generated content is not permitted on Ask Ubuntu
  • Goodbye Gunnar Hjalmarsson 1958.10.06 - 2023.12.20

Hot Network Questions

  • What's the relation between a language being managed and its compiler being reversible?
  • Why does the Falcon 9 first stage perform a burn at 60 km altitude?
  • Swap letter cases
  • How could a speedster function in real life. Part 1:Acceleration
  • Names in The Water Margin
  • Xfig installed by homebrew: segmentation fault
  • How to answer vague "tell me about x" questions from recruiter
  • What happens when the runway is unusable at an isolated aerodrome?
  • Does over refrigerator cabinet need support at both ends?
  • Why deplane all passengers and not the troublemaker?
  • Equation of Motion Invariance in Galilean Mechanics
  • How do you make nice recess in a melamine board for IKEA shelf holders?
  • Why was the standard distance set to 10 parsec and not simply to 1 parsec?
  • Horror short story set on Everest, where climbers left behind are eaten by a creature masquerading as a climber
  • Kitchen sink slow drainage and P-Trap installation
  • Will MLE always produce Biased Variance Estimates?
  • Newbie: How to identify a chip on a board, what is the best strategy?
  • Is the realization of random variable also a random variable?
  • Can I use references when I am responding to Reviewer in Revisions
  • Does this 8088 code in the Leisure Suit Larry 2 game actually do anything?
  • How to generate a complicated table
  • A weird probability question
  • What is the definition of 909/808/707/etc. percussion?
  • Is there any chance a Japanese person would understand this spoken line WITHOUT kanji? [Attack on Titan]

how to setup a static ip on ubuntu server

XDA Developers

Create a home server from your old laptop

Quick links, benefits of using a laptop as a server, potential problems with a laptop server, choosing an operating system, how to set up your laptop as a home server.

Whether you're a full-time tech-hoarder like me or just thinking about upgrading an aging device, it can be difficult to find a good use for an old laptop. It doesn't make much sense to keep a spare one at home, and most of us buy and replace laptops on a cycle of necessity, not simply because there's a new model out or our SIM contract is up. It's also not always easy to upgrade laptops. And depending on the model and age, they suffer wear-and-tear easily, which makes them more difficult to donate or pass on to a relative.

One great use of an aging laptop is as a simple, low-power home server.

Power efficiency is king for home servers

One big consideration for any device that will be used as a home server is power efficiency. This is often the problem with picking up used server hardware on the cheap (and they can be very cheap) — the power requirements for an aging machine can be ridiculous. This might be less of a concern if you're based somewhere with cheaply available wall power, but in Europe, particularly, this can be a serious consideration. Laptops are designed to run on batteries to start with, and they often feature low-power versions of chips designed with this in mind.

Upgrades are often cheap

It's often relatively inexpensive to upgrade the memory of your aging laptop. There are obvious caveats to this — most laptops won't support more than 32GBs, but for a simple home machine, this is probably plenty.

For example, a single-DIMM 32GB memory upgrade for my old XPS 15 will run about $100. While not exactly cheap, this is far cheaper than buying a new machine, and it isn't too far from the price you would pay to install that amount of memory in a dedicated home server.

The same applies to storage. Most laptops support only a single drive, so no easy redundant array of independent disks (RAID) here. But the capacity of single-drive SSDs has gone up significantly in the last few years. It's now easy to get a SATA or M.2 SSD with capacities in the 4TB or 8TB range. Although the latter might be pricey, 4TB SATA drives are available on Amazon now for under $250.

Most laptops are quiet

This one is more in line with the argument against buying old server hardware on the cheap: it's often annoyingly loud. If you've ever been around enterprise-level great servers or network hardware, one thing you can't miss is their noise. It's similar to being in the same space as a high-powered vacuum cleaner, albeit at a slightly higher pitch.

Laptops are designed to run quietly out the box. Not all laptops are quiet — I definitely wouldn't use my 2018 MacBook Pro as a home server — but with some tweaking of power-settings, most can be configured to run quietly enough that they won't be audible in a side cupboard or some other out-of-the-way spot in your home.

Small footprint

One of the biggest benefits of using a laptop as a home server is its small footprint. Laptops can be easily slipped into a cupboard, a TV unit, or on a shelf somewhere. You'll want to avoid storing your laptop-cum-server anywhere it might collect excessive dirt or dust, get easily bumped, or have insufficient airflow to keep it cool.

No need for Ethernet

Ethernet is king. But, when it comes to most of our uses for home servers, you're unlikely to be maxing out Wi-Fi. Whether you're able to hook a home server to Ethernet will depend on your own unique circumstances. But one of the great benefits of using an old laptop is that they've got Wi-Fi built in, so the option is there. This also gives you more flexibility in where you store your home server: with Wi-Fi access, anywhere with a power outlet will do.

Built in UPS?

This one's a little more audacious. In theory, laptops come with a great free universal power supply (UPS). Practically speaking, though, leaving your laptop plugged in and running constantly is likely to significantly degrade the battery. Some people suggest removing the battery entirely when the laptop is on AC power for an extended period, but this depends on your laptop model and whether your battery is charged and cycled properly when on AC power for an extended period.

Leaving the battery in can generate excessive heat on some laptops. On the other hand, some laptops may also perform significantly worse when the battery is removed. Our advice is to leave the battery in. If you experience significant heat dissipation issues, test this factor with the battery removed.

You should also be aware that leaving the battery in your laptop presents an increased fire risk.

Err on the side of caution when it comes to heat dissipation

One big issue with using a laptop as a home server concerns heat dissipation. We'll be showing you how to set up your laptop to run 24/7 with the lid closed, but most laptops aren't really designed to run like this. You'll want to keep a close eye on temperatures to get started with, and make sure you don't leave your laptop for an extended period during your initial testing.

Limited potential for storage upgrades

One of the big problems with using your laptop as a home server is the limited potential for storage upgrades on offer. Most laptops support only one internal drive, and while you can hook up external disks, this will quickly become cumbersome. The single internal drive also means you'll be unable to use RAID to stripe your disks and gain additional protection for your data.

For this reason, we wouldn't recommend using a laptop as a home NAS or media server for important documents, pictures, and media.

Windows isn't great for server use cases, but there are options

Your operating system makes a big difference when running your home server. We'll be using Ubuntu Desktop, but if you feel more comfortable using the terminal to manage your server day-to-day, you can use Ubuntu Server (we've previously covered some of the differences and use cases for each ).

You can use Windows for your home server, but we wouldn't recommend it. It can be more difficult to configure for many common use cases, and this approach is heavier on performance.

If you are using Ubuntu Desktop, one great option instead of Secure Shell (SSH) is to set up virtual network computing (VNC). We've already got a great guide on setting up remote access on Ubuntu . Similarly, if you're using Windows you can set up Remote Desktop to access your server.

Install some simple tools to get started

Next, we'll show you how to set up the bare bones of a great headless home server running Ubuntu. We'll be using Ubuntu Server, but you may also want to use Ubuntu Desktop, depending on the applications and tools you're planning on running.

We recommend that you make any required upgrades to your laptop in advance; it'll only be harder to set up your machine and make hardware changes later. We've already got great guides on how to install Ubuntu Desktop , and Ubuntu Server is largely the same process (minus a few steps, even.) You can download an Ubuntu Server ISO from Ubuntu's website. We'd recommend installing the full version, not the minimized version, as it contains some tools we'll need later.

Once Ubuntu Server is installed, we'll be making a few changes. First, we'll connect to a network. If you've already done this in the installer, you can skip this step. After Ubuntu is installed, we'll make a few small changes.

Set up SSH access on Ubuntu

In order to access your Ubuntu instance headlessly (that is, without a monitor attached), you'll want to set up SSH. Before doing this, make sure your laptop has a static IP address.

  • To check your existing IP address, type the following in a terminal: ip addr Locate your network interface (prefixed with either enp for Ethernet or wla for Wi-Fi) and look for an inet ipv4 address below that.
  • Once you've found your network interface and address, open /etc/netplan/01-netcfg.yaml in a text editor. Sometimes this file is called 50-cloud-init.yaml . We're using Nano here again. To check, run the following: sudo ls /etc/netplan/ And then run this command to open the file: sudo nano /etc/netplan/50-cloud-init.yaml You should see your connected network interface.
  • Modify the file to disable Dynamic Host Configuration Protocol (DHCP). DHCP is responsible for automatically assigning IP addresses on your home network. Set dhcp4 to false .
  • You'll then need to add a network configuration. We'll be using the same IP address assigned by DHCP but setting it as a static IP . This ensures that it persists over time and between reboots. Add the following block to your file, replacing the placeholder value with the IP address you saw in Step 1. You can find your Gateway IP by replacing the final block of your IP address (for example, replace 192.168.1. 155 with 0, thus giving you 192.168.1.1) .
  • Save the file
  • Reload your network configuration by running: sudo netplan apply

Once you've configured a static IP, you can set up SSH. We've already got a great guide on configuring SSH for Ubuntu .

Disable sleep when the lid is shut

By default, the Ubuntu Desktop will sleep when the lid of your laptop is shut. You can change this behavior with some small tweaks to the power settings.

  • Open /etc/systemd/logind.conf in a text editor of your choice. Again, we're using Nano. sudo nano /etc/systemd/logind.conf
  • Edit the following lines, removing the comment (#) at the start of each line, and change the value after the = sign. HandleSwitchLock=ignoreHandleSwitchLidExternalPower=ignore This setting modifies how Ubuntu's init-system systemd handles the lid closing. The default value is suspend .
  • Reboot your laptop, either by pressing the power button or by typing the following in the terminal: sudo reboot

Monitor your laptop's temperatures

Now that you've got your laptop set up with remote access over SSH, you're free to close the lid and hide it in a corner somewhere. We've mentioned that temperatures can be problematic when running a laptop with the lid closed for a long period, so we'll show you how to monitor your temperatures on an ongoing basis by using lm-sensors .

  • Install lm-sensors with apt : sudo apt- get install lm-sensors
  • Detect your device's sensors. This will ask you a series of YES/NO questions. We'd recommend answering YES to the first question, and NO to the rest. sudo sensors-detect
  • Once your sensors are detected, you can check their values with: sensors

We'd recommend setting up a few services on your new home server and carefully monitoring the temps once it's placed in position. If you're going to be running any burst-driven high-intensity workloads (like video encoding), consider running an artificial benchmark for a short period and then checking if your temperatures remain an acceptable range.

Breathe life into your old hardware

We've walked through some of the ways your old laptop could make a great home server. Particularly if you're in a small apartment, there are some real benefits to using a Wi-Fi enabled, quiet, and compact bit of hardware to run your basic home services. Just be sure to regularly dust your laptop (ideally with compressed air), and keep an eye on its temperature when the lid is shut.

As mentioned earlier, we don't recommend using a laptop server as a NAS, as it's not easy to achieve sufficient data redundancy in the case of a drive failure. The heat of a closed laptop might also make your hardware more prone to failures — particularly SSDs. But for other purposes, laptops are a great starting point for running your own services at home, and they shouldn't require any significant expense to get started.

Create a home server from your old laptop

  • VMware Technology Network
  • Cloud & SDDC
  • vSphere Replication
  • vSphere Replication Discussions

VRMS add-on with no IP: how to set a static one?

  • Subscribe to RSS Feed
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Printer Friendly Page

marauli

  • Mark as New
  • Report Inappropriate Content
  • All forum topics
  • Previous Topic

IMAGES

  1. How to Configure Static IP Address on Linux System

    how to setup a static ip on ubuntu server

  2. How to Set a Static IP Address in Ubuntu

    how to setup a static ip on ubuntu server

  3. How to Configure Static IP Address on Ubuntu 20.04

    how to setup a static ip on ubuntu server

  4. How to Configure Static IP Address on Ubuntu 20.04

    how to setup a static ip on ubuntu server

  5. How to Configure Static IP Address on Ubuntu 18.04

    how to setup a static ip on ubuntu server

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

    how to setup a static ip on ubuntu server

VIDEO

  1. Howto Setting IP in UBUNTU 18

  2. How to assign Static IP Address in Ubuntu 17.04

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

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

  5. How To Configure Static IP on Ubuntu 22.04 (Jammy Jellyfish)

  6. How to Set Static IP in Ubuntu Server 20.04 -IP شرح كيفية تثبيت

COMMENTS

  1. How to Configure Static IP Address on Ubuntu 20.04

    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 The command prints a list of all the available network interfaces. In this example, the name of the interface is ens3:

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

  3. How to Set Static IP Address on Ubuntu Server 22.04

    In Ubuntu server 22.04, networking is controlled by netplan utility, so we will use netplan to configure static ip address on Ubuntu server. Note: we cannot use nmcli utiltity as it is not the part of default installation on Ubuntu server. Setting up Static IP address on Ubuntu Server 22.04

  4. How to Set Static IP Address on Ubuntu Server (Step-by-step)

    On Ubuntu Server, the network configuration is managed by the netplan utility, with the configuration file located in /etc/netplan. It's possible to set a static IP by editing this file. Before making any changes, make sure you understand your network configuration and find a free IP address for your server (I will explain how to do this).

  5. Set static IP in Ubuntu using Command Line

    Set static IP in Ubuntu using Terminal Pratham Patel Dec 5, 2022 Table of Contents 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.

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

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

    Step 1 : Open /etc/netplan/50-cloud-init.yaml and find the following lines: dhcp4: true Step 2 : Change the preceding lines to add an IP address, net mask, and default gateway (replace samples with the respective values): addresses: [192.168.1.80/24] gateway4: 192.168.1.1 nameservers: addresses: [8.8.8.8,8.8.4.4] dhcp4: no

  8. How to Assign Static IP Address on Ubuntu Linux

    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: nmcli d In my case, it shows my Ethernet (wired) network is called enp0s25: Ubuntu> nmcli d

  9. Linux Basics

    This tutorial explains how to set up a static IP address on an Ubuntu system from the command line. It covers network configuration for all current versions of Ubuntu and includes instructions for configuring a static IP address, setting the hostname, and configuring name resolution.

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

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

  12. How to Configure Static IP Address on Ubuntu 18.04

    The first step is to identify the name of the ethernet interface you want to configure. To do so use the ip link command, as shown below: ip link The command will print a list of all the available network interfaces. In this case, the name of the interface is ens3:

  13. How to Configure Static IP Address on Ubuntu 22.04 LTS and 22.10

    It's pretty easy to configure Ubuntu 22.04 static IP settings using the nmcli command. nmcli is a text-based utility used to check the status of the wired connections you are using on your device.

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

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

    Mar 8, 2021 at 7:33. Add a comment. 64. Setting the static IP address as above in the accepted answer here works, but one has to flush the old IP addr setting and then restart networking.service: sudo ip addr flush enp0s25. sudo systemctl restart networking.service. Then verify it is correct: ip add.

  17. How to Configure Static IP Address on Ubuntu Server 22.04

    When you install Ubuntu server, the network setup is set to static IP addressing by default, which is not ideal. In this chapter, you will learn how to configure a network interface to have a static IP address assigned to it. Step 1 : Use the following command to get a list of accessible Ethernet interfaces.

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

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

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

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

  21. How to setup a static IP on Ubuntu Server 18.04

    Ask Question Asked 5 years, 10 months ago Modified 1 year, 11 months ago Viewed 167k times 48 I've seen some people saying the file to set static ip is still /etc/network/interfaces And I've seen other people saying that in 18.04 it's now on /etc/netplan (which people seem unhappy about) I've tried putting this: version: 2 renderer: networkd

  22. Netplan static IP on Ubuntu configuration

    Select IPv4 from the top menu. Select IPv4 to start configuring a new IP address. Choose Manual for the IPv4 settings, enter your desired configuration and hit Apply . Set your desired static IP address. Restart your network by ON/OFF switch. Restart to apply new network settings.

  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. Create a home server from your old laptop

    Once Ubuntu Server is installed, we'll be making a few changes. First, we'll connect to a network. ... Once you've configured a static IP, you can set up SSH. We've already got a great guide on ...

  25. Assigning static ip to multipass vms : r/Ubuntu

    hello, i was thinkering with and old laptop of mine, i installed ubuntu server 22.04 in and multipass, the mean perpose is create on premises k8s cluster using kubeadm, after lunching 3 ubuntu vms with the multipass lunch command. what i want is to set a fixed ip for each vm to be able to communicate with locally and to reduce network issues while working with k8s cluster. example: cp1: 172.10 ...

  26. How to configure static IP address on Ubuntu 22.04 Jammy Jellyfish

    Open network settings from top right corner of GNOME desktop Next, click on the gear box icon next to your network connection you wish to configure. This could be wired or wireless connection. Open the network settings of the interface that you want to configure Click on the IPv4 or IPv6 tab, depending on which type of IP you want to configure.

  27. VRMS add-on with no IP: how to set a static one?

    I poked around Ubuntu forums, looked for netplan, network manager, ... (primary - or add-on) and setting a static IP on it - results in a botched network configuration where all or most settings used during deployment are ignored. (The bug appears to exist for a number of years and affect a lot of people on reddit, SO, and similar sites - yet ...

  28. Setting Up GPT4All on Ubuntu/Debian Linux

    Raspberry Pi as Minecraft Server; Setting Up GPT4All on Ubuntu/Debian Linux; Setting the Root Password on Ubuntu 24.04 Linux; Cloud Gaming with GeForce NOW on Ubuntu / Debian Linux; Setting the Hostname on Ubuntu 24.04; Setting a Static IP Address in Ubuntu 24.04 via the Command Line; Quick Guide to Enabling SSH on Ubuntu 24.04