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

assign ip in ubuntu

Step 2: See current IP address

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

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

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

Step 3: See the gateway

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

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

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

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

Make a note of your gateway address.

Step 4: Set static IP address

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

Step 4-A: Disable cloud-init if present

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

Run the following command to check:

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

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

Add the following line to it:

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

Back to Step 4

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

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

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

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

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

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

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

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

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

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

To apply the settings, run the following command:

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

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

Perfect! The IP address has now changed successfully.

assign ip in ubuntu

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

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

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

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.

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

Tecmint: Linux Howtos, Tutorials & Guides

How to Configure Static IP Address on Ubuntu 20.04

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

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

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

Network Configuration

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

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

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

On this page

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

How to Set Static IP Address On Ubuntu Desktop

To get started, Launch ‘ Settings ’ from the application menu as shown.

Ubuntu Settings

On the window that appears, click on the ‘ Network ’ tab at the left sidebar and then hit the gear icon on the network interface that you wish to configure. In my case, I’m configuring my wired interface.

Ubuntu Network

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

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

Ubuntu Network Configuration

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

Ubuntu Network Method

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

Set Manual Network

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

Set Network DNS

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

Enable Network Connection

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

Verify Network Configuration

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

Check IP Address

To confirm the DNS servers, run the command:

Check DNS Servers

How to Set Static IP Address on Ubuntu Server Using Netplan

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

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

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

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

Netplan YAML File

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

Default Network Settings

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

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

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

Check Ubuntu Server IP Address

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

Previous article:

Next article:

Photo of author

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

Related Posts

Configure Network Ethernet Connection Using nmcli Tool

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

Linux IP Address

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

Differences Between IPv4 and IPv6

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

Linux Network Information Tool

What IP – A Network Information Tool for Linux

Configure Network Interface in CentOS 7

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

Create NIC Teaming in CentOS

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

I hope this answers your question.

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

Thank you very much Jaidev Shah. Keep it Tecmint.

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

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

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

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

/etc/NetworkManager/system-connections/

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

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

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

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

Hello Nikon,

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

http://linuxsay.com/

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

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

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

This depends on few things:

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

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

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

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

“restarting networking (via systemctl): networking service”

Both scripts do the same.

Why not use systemd to restart networking directly?

`systemctl restart network`

Got something to say? Join the discussion. Cancel reply

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

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

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

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

How do I set a static IP address?

My eth0 is using DHCP to get IP address for Internet. However I still need to set some static IP for my LAN. The following is my setting in /etc/network/interface. Any problem on the script ? I always failed when I try to start network.

I checked the IP via ifconfig. and found eth0:3 is set but others. May I know what's the problem?

Jorge Castro's user avatar

  • possible duplicate of How to set static ip address in guest Ubuntu running in Virtual Box –  Andrea Corbellini Aug 20, 2014 at 16:47

3 Answers 3

You don't really need to edit `/etc/network/interfaces' to set the static IP addresses. You can do that using the Network Manager. Just right click on the network applet and go to Edit Connections.

If you however don't want to use the network manager, the following steps will help you assign multiple ip addresses:

  • Disable the network manager sudo service network-manager stop
  • Get the IP address from the server using: sudo dhclient eth0
  • Assign the first ip addresses like this: sudo ip addr add 192.168.20.222/24 dev eth0 , and repeat for other IP addresses.
  • Add the default route using: sudo route add default gw <internet gateway ip address>

If you do step 2, step 4 is not required. Hope that helps.

The Terminator's user avatar

  • thanks. I prefer use Network-manager. but when I edit the connection and add two more static ip address and then reboot. Then the ip change to lan only, I lost my dhcp ip address. –  iAsk Mar 7, 2012 at 5:12
  • Well then go with the command line. –  The Terminator Mar 7, 2012 at 10:11
  • command line is easier, but I need to input password every time. thanks –  iAsk Mar 7, 2012 at 11:19
  • sudo su will relieve you of that trouble. –  The Terminator Mar 7, 2012 at 16:53
  • sudo su still need input password, how come to relieve the trouble. –  iAsk Mar 13, 2012 at 6:11

If you have NetworkManager installed, it could be causing a problem with /etc/network/interfaces. See /usr/share/doc/network-manager/README.Debian (I've used Ubuntu just enough to install it for someone else).

ashley willis's user avatar

  • can network manager achieve some work? I tried to assign static IP in network manager and also failed. –  iAsk Mar 7, 2012 at 3:18

If the problem persists while setting up a static ip, use the following steps to set up a new static ip address:

Open terminal (command line) and type the following command:

Make the changes as follows:

Save and close the file. Restart networking:

amc's user avatar

You must log in to answer this question.

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

  • The Overflow Blog
  • Would you trust an AI bot to find the fix for vulnerabilities in your code?
  • Featured on Meta
  • Site maintenance - Saturday, February 24th, 2024, 14:00 - 22:00 UTC (9 AM - 5...
  • Upcoming privacy updates: removal of the Activity data section and Google...
  • Notifying users about the policy on AU concerning AI-generated content
  • AI-generated content is not permitted on Ask Ubuntu

Hot Network Questions

  • Is it possible for truth to be set by humans?
  • Why is everything based on likelihoods even though likelihoods are so small?
  • Is there any satellite that uses LOX as oxidizer?
  • Adding List-Unsubscribe Header to SFMC Transactional Emails via Messaging API
  • GeoServer keeps redirecting to http://
  • Hiding a star cluster
  • Is there a perfect group in which not every element is a commutator?
  • Increasing trust in a downloaded binary
  • Ingenuity extended static mission science possibilites
  • British Duke is murdered in elevator. Title is inherited by one of a pair of identical twins, both of whom are suspects
  • Can a function be defined as the union of two other functions?
  • Magical Spellchecker
  • Odd use(s) of "bauen"
  • Add rules to Minesweeper until you can start with nothing
  • Periodic boundary conditions: torus or infinite images?
  • Is it legal for a bank to trap you in an ATM vestibule?
  • What's the word similar to jittery in spelling or pronunciation, but means some privately-run transportation by small vehicles?
  • What will happen after `zip *` executes?
  • Is this 240v circuit to garage for electric charger good or did I miss something?
  • Anna and Boris play the Red Blue game
  • How can Australia can be a member of the Antarctic Treaty while still making a territorial claim in the region?
  • Why is the key typically the first and/or last note (or chord) of a song?
  • Motivation for the definition of curvature of a plane curve
  • Re-heat Sous Vide Roast Beef

assign ip in ubuntu

How to assign static IP address on Ubuntu Linux

Here are the steps to assign an IP address to an Ubuntu Server using the Settings app and Terminal commands.

Avatar for Mauro Huc

On Ubuntu (version 22.04, 21.04, or older releases), it’s possible to assign a static IP address through the Settings interface or the Terminal using commands, and in this guide, you will learn how.

Once you complete the installation of the Ubuntu Server (or client version), the device will receive a network configuration assigned automatically by the Dynamic Host Configuration Protocol (DHCP) server available in the local network. Although this configuration is enough to access the network and internet, it’s a good idea to assign a static network configuration as you probably are setting up the system to serve different services, such as file and print sharing and others.

The reason is that a dynamic configuration can change at any time, and a static network configuration is permanent, meaning that devices in the network will be able to always reach the server with the address.

This guide will teach you the steps to configure a static IP address for your Ubuntu Server installation. You can also use these instructions for the client version of the Linux distro.

Set static IP address configuration on Ubuntu Linux (GUI)

Set static ip address configuration on ubuntu linux (command).

To assign a static IP address on Ubuntu (server or client) through the Settings app, use these steps:

Open Settings .

Click on Network .

Click the Settings button for the “Wired” network interface.

Ubuntu network open settings

Click the IPv4 tab.

Select the Manual option for the “IPv4 Method” setting.

Under the “Addresses” section, confirm the static IP address in the “Address” setting — for example, 10.1.4.201.

Ubuntu assign static IP address

Confirm the subnet mask in the “Netmask” settings — for example, 255.255.255.0.

Confirm the gateway address (usually the router’s IP) in the “Gateway” setting.

Turn off the Automatic toggle switch for the “DNS” setting.

Confirm the DNS address(es) for this static configuration — for example, the router IP address or your preferred DNS address, such as the ones from Google Public DNS, 8.8.8.8, 8.8.4.4 .

(Optional) Click the IPv6 tab.

Select the Disable option in the “IPv6 Method” setting.

Click the Apply button.

(Optional) Turn off and on the Wired toggle switch on the “Network” page if the configuration isn’t working.

Once you complete the steps, the Linux distro will start using the new static network configuration.

To assign a static IP address on Ubuntu Linux (server or client), use these steps:

Open Terminal

Type the following command to determine the network interface name and press Enter :

Ubuntu view IP config command

Type the following command to open the configuration file and press Enter :

Copy and paste the following configuration (changing the TCP/IP settings with your settings):

In the command, change “ens33” for the name of your server network adapter name and “10.1.4.201/24” for the static IP address and subnet mask after the forward slash (/) you want to assign to the Ubuntu Server. For example, the “/24” assigns the “255.255.255.0” address. Also, change “8.8.4.4, 8.8.8.8” for static DNS addresses. The comma (,) is only required when setting up multiple addresses. And change “10.1.4.1” for the default gateway of your network (usually the router IP address).

Ubuntu static IP set commands

Press “Ctrl + O,” “Enter,” and “Ctrl + X” to save the changes and exit the text editor.

Type the following command to apply the new static IP address configuration and press Enter :

(Optional) Type the following command to confirm the static network configuration and press Enter :

Ubuntu confirm IP address

In the command, change “ens33” to the name of the adapter.

After you complete the steps, the static  IP address configuration will apply to the network adapter on Ubuntu (server or client).

  • How to backup config file on TrueNAS
  • How to create Windows Server bootable USB media

UbuntuMint – Everything About Ubuntu Linux

How to Set Static IP Address on Ubuntu Linux

On Ubuntu 18.04 and later versions, there is a new way to set an IP address i.e., Netplan . This tutorial describes how to set an IP address from the command line on Ubuntu Linux by using the Netplan utility.

Set an IP Address with Netplan on Ubuntu

Netplan is the new way to set an IP address on newer versions of Ubuntu ( Ubuntu 18.04 and later.) With netplan , network configurations are consolidated and saved under /etc/netplan with a .yaml extension.

Firstly, run the command below to change into the netplan directory and then list the contents of the netplan directory as follows.

You should see the default Netplan configuration file. Mine is named 01-network-manager-all.yaml on my Ubuntu 20.04 machine. Yours might be named something slightly different, depending on your Ubuntu version.

Netplan Configuration Files

It is advisable to create a backup of the default netplan configuration file as follows.

Next, run the command below to confirm the name of the network interface for which you want to set an IP address.

Check Network Interface Name

In this example, I am working with network interface eth0 .

Configure IP Address in Ubuntu

Now, open the default Netplan configuration file for editing with the command below.

You would need to make changes to the file so that it looks similar to what you see in the image below. In my case, the new additions are marked with a red border.

Configure IP Address in Ubuntu

Note : Proper indentation is important when working with YAML configurations. You do not have to use the exact same spacing in my example above. You may choose to use a fixed number of spaces for each level of indentation.

Save and close the configuration file.

Next, run the following command to check for syntax errors in the Netplan configurations.

Test Netplan Configurations

When prompted, press enter to accept the configuration. If the configuration is accepted, you are on course. Otherwise, review your configuration and test again.

Apply Netplan and Verify IP Address

Finally, apply your Netplan configurations with the command below.

You may now verify your updated network settings as follows.

Check IP Address in Ubuntu

In this tutorial, we described the steps to set an IP address on Ubuntu by using the Netplan utility. We hope that you find this very helpful.

How to Batch Convert PNG Images to JPG Format in Linux

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

Photo of author

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

RECOMMENDED ARTICLES

How to Find Network MAC Address in Linux System

How to Change Network MAC Address in Linux

How to Set a Static IP Address in CentOS Linux

How to Check Linux Network Statistics from Command Line

How to Check a Port is Open on a Remote Linux System

Got something to say? Join the discussion. Cancel reply

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

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

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.

ITzGeek

How to Set a Static IP Address On Ubuntu 22.04

assign ip in ubuntu

The first task anyone would do after installing Ubuntu is setting an IP address to a system to connect to the network/internet. If the Wi-Fi router, ISP, or network doesn’t provide DHCP services, you must manually assign IP addresses.

Here, we will see how to set a static IP Address on Ubuntu 22.04, using,

  • GNOME Control Center
  • NetworkManager

You can use any method to set a static IP address on Ubuntu 22.04.

Find Network Interfaces on Ubuntu 22.04

You can run any of the below commands in a terminal to get a list of network interfaces available on the system.

The output of the ifconfig command on a desktop:

The output of the ifconfig command on a laptop:

Here, we will see how to configure a static IP for enp0s3 (Wired) / wl01 (Wi-Fi).

IP Address : 192.168.0.10 Netmask : 255.255.255.0 Gateway : 192.168.0.1 DNS Server 1 : 192.168.0.1 DNS Server 2 : 8.8.8.8 Domain Name : itzgeek.local

Set Static IP Address on Ubuntu 22.04 Desktop

1. using gnome network manager.

Using the GNOME network control center to set a static IP address on In Ubuntu 22.04 desktop is straightforward.

Set IP for Wired Interface using GNOME

Open the Gnome control center using the gnome-control-center network command or go to Activities >> Settings >> Network .

Click on the gear icon on the Wired interface page and then IPv4 tab >> Manual >> Enter IP address, Netmask, Gateway, DNS (Toggle to disable Automatic DNS configuration) >> Apply .

Set IP for Wired Interface

Finally, use the toggle in the Network page to disable and enable the network interface to apply the IP address.

Set IP Address for Wi-Fi using GNOME

Open the Gnome control center using the gnome-control-center wifi command or go to Activities >> Settings >> Wi-Fi .

Click on your Wifi router name and then enter the router’s password to connect. Your laptop will automatically receive an IP address from a Wi-Fi router with a built-in DHCP service on a successful connection.

Wi-Fi Access Points

To assign a static IP address or Wi-Fi interface, click on the gear icon on the Wi-Fi interface page and then IPv4 tab >> Manual >> Enter IP address, Netmask, Gateway, DNS (Toggle to disable Automatic DNS configuration) >> Apply .

Set IP for Wired Wi-Fi

Finally, disable and enable the Wi-Fi interface to apply the IP address.

2. Using Netplan

Netplan is a utility for easily configuring networking on a Ubuntu system. It reads the configuration files .yaml present in the /etc/netplan directory.

This utility supports both networkd and Network Manager as backends. However, using Network Manager as a backend renderer: NetworkManager is recommended for the Ubuntu desktop. The remaining configurations are the same as that of the networkd .

3. Using NetworkManager CLI

Set ip for wired interface using nmcli.

First, let us list the available network connections.

Then, configure static IP address to wired interface.

Finally, run the below commands to apply the IP address.

Set IP Address for Wi-Fi using nmcli

First, list the available Wi-Fi access points using the below command.

Next, connect to the Wi-Fi access point.

And then, configure static IP address to Wi-Fi interface.

Finally, run the below commands to apply the IP address

Set Static IP Address Using NetPlan on Ubuntu 22.04 Server

Netplan is a network configuration utility that reads YAML files and generates all network configurations for the renderer tool (NetworkManager or networkd) to configure the network on a system.

Netplan configuration files are found in the /etc/netplan/ directory.

Remove any configuration files .yaml present in the /etc/netplan directory.

Set IP for Wired Interface using Netplan

Now, create a new netplan configuration for the wired network interface.

Then, make changes to the below information and use it for your requirement.

And then generate the required configuration for the renderers.

Finally, apply all network configurations and restart renderers.

Set IP Address for Wi-Fi using Netplan

Wi-Fi Interface Name : wl01 Wireless Access Point Name : Raj Wireless Access Point Password :  MyPass

First, create a new netplan configuration for the wired network interface.

Verify Static IP Address on Ubuntu 22.04

Verify the static IP address using the below commands.

Also, verify the DNS server’s entries.

That’s All.

How to Install Brave Browser on Fedora 36 / Fedora 35

How to Install phpMyAdmin with Nginx on Ubuntu 22.04

How to Install MySQL on Ubuntu 22.04

How to Install Cacti on Ubuntu 22.04

How to Install pgAdmin on Ubuntu 22.04 / Ubuntu 20.04

How to Set up DNS Server on Ubuntu 22.04 / Ubuntu 20.04

How to Install PostgreSQL on Ubuntu 22.04

How to Install Plex on Ubuntu 22.04

  • CentOS 8 / RHEL 8
  • CentOS 7 / RHEL 7
  • CentOS 6 / RHEL 6
  • LinuxMint 20
  • Linux Mint 19
  • Linux Mint 18
  • Rocky Linux 8
  • Ubuntu 22.04
  • Ubuntu 20.04
  • Ubuntu 18.04
  • MySQL / MariaDB
  • Other Tools

DeviceTests.com Logo

How To Assign an IP Address in Ubuntu Server 20.04.3 Using Command Line

Carlos Bradley

In this guide, we will walk through the process of assigning an IP address in Ubuntu Server 20.04.3 using the command line. This is often necessary for setting up servers or network-related applications.

To assign an IP address in Ubuntu Server 20.04.3 using the command line, you can use the Netplan configuration utility. Open the Netplan configuration file, modify the network interface settings to specify a static IP address, gateway, and DNS servers, save the changes, and apply the new configuration using the sudo netplan apply command. Verify the assigned IP address using the ip addr show command.

Introduction to Netplan

Starting from Ubuntu 17.10, the /etc/network/interfaces file is no longer used by default. Instead, Ubuntu now uses Netplan , a new command-line network configuration utility, to manage and configure network settings easily in Ubuntu systems.

Netplan reads network configuration from /etc/netplan/ , where you can store .yaml files. It is more powerful and flexible than the old method and allows for more complex configurations.

Accessing the Netplan Configuration File

To assign an IP address, you need to edit the Netplan configuration file. Here’s how you can do it:

  • Open the terminal.
  • Type the following command to open the Netplan configuration file using the nano text editor:

Note: The filename may vary depending on your system.

This command uses sudo for administrative privileges, nano as the text editor, and /etc/netplan/00-installer-config.yaml is the location and name of the Netplan configuration file.

Configuring the IP Address

Inside the file, you will see a YAML structure similar to the following:

In this example, the network interface ens18 is set to use DHCP (Dynamic Host Configuration Protocol), which means the IP address is automatically obtained from the DHCP server.

To assign a static IP address, modify the configuration to something like this:

In this configuration:

  • ens18 is the name of your network interface. Replace it with your network interface name.
  • addresses specifies the static IP address and subnet mask (e.g., /24 for a 24-bit subnet).
  • gateway4 specifies the IP address of the gateway (router).
  • nameservers specifies the IP addresses of the DNS servers.

Applying the Configuration

After editing the configuration, save the changes and exit the text editor. To save and exit in nano, press Ctrl+X , then Y , then Enter .

Finally, apply the new configuration by running the following command:

This command will apply the changes you made to the configuration file.

Verifying the IP Address

After applying the Netplan configuration, your network interface should have the assigned static IP address. You can verify it by running the ip addr show command:

This command will display the network configuration of all network interfaces. Look for your interface and check if the IP address is correctly assigned.

Assigning an IP address in Ubuntu Server 20.04.3 using the command line can seem complex at first, but once you understand the structure of the Netplan configuration file, the process becomes straightforward. Remember to adjust the configuration according to your network setup. If you encounter any issues, make sure to check the Netplan documentation or seek further assistance.

Netplan is a command-line network configuration utility used in Ubuntu systems to manage and configure network settings easily. It reads network configuration from /etc/netplan/ and allows for more complex configurations compared to the previous method using the /etc/network/interfaces file.

To access the Netplan configuration file, open the terminal and type the following command: sudo nano /etc/netplan/00-installer-config.yaml . This command opens the Netplan configuration file using the nano text editor. Please note that the filename may vary depending on your system.

To assign a static IP address using Netplan, you need to modify the Netplan configuration file. Inside the file, locate the YAML structure for your network interface and modify it to include the desired static IP address, subnet mask, gateway, and DNS servers. Save the changes and apply the configuration using the sudo netplan apply command.

After applying the Netplan configuration, you can verify if the IP address is correctly assigned by running the ip addr show command in the terminal. This command will display the network configuration of all network interfaces. Look for your interface and check if the IP address is correctly assigned.

If you encounter any issues or need further assistance, you can refer to the Netplan documentation . It provides detailed information on various configuration options and troubleshooting steps.

Related Posts

Ubuntu 15

Update-grub vs Update-grub2: What’s the Difference?

Ubuntu 6

How To Fix Fuzzy Graphics on Ubuntu 20.04 with Intel HD Graphics 520

Ubuntu 11

How To Install Ubuntu Alongside Windows Using ‘Something Else’

Ubuntu 15

How To Run a Web URL Script in Terminal

Ubuntu 14

How To Boot to Root Shell When GRUB Recovery Menu Fails

Ubuntu 7

How To Change Tor’s IP Address Using Terminal Commands

About the author, carlos bradley, leave a comment cancel reply.

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

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

Carlos Bradley is a developer by day and an author by night. All of the computer tests on DeviceTests.com have been developed by Carlos.

Ubuntu 8

How To Remove Executable Using Make Clean

Ubuntu 4

How To Check SSD Health in Ubuntu Linux

Ubuntu 11

How To Revert Alt-Tab Behavior in Unity to Switch Between Windows on Current Workspace

TecAdmin

How to Configure Static IP Address on Ubuntu 22.04

After installing Ubuntu 22.04 the default network interface assigns an IP address using the DHCP server. Also, the wireless network will be active and enable networking over the wifi network.

You can also configure the network interface with static IPv4 addresses. Ubuntu 22.04 uses the Netplan as a network manager.

This tutorial helps you to configure network interfaces on Ubuntu 22.04 Desktop and Ubuntu 22.04 Server editions. The desktop users can use any one of the below methods but the server users that have CLI only access use the second method to edit network interface configuration files.

Method 1: Configuring Static IPv4 Address on Ubuntu 22.04 Desktop

The Ubuntu Desktop editions have a graphical interface for configuring the network interfaces. Follow the below steps to configure a static IP address on Ubuntu 22.04 Desktop system.

  • Click the network icon in the upper-right corner.
  • Then expand the Wired Connected dropdown.
  • Now, click on Wired Setting as shown below image.

Configuring Static IP on Ubuntu 22.04

  • A network settings dialog box will appear.
  • Now, click “Network” in left sidebar.
  • Under the Wired section, click the Gear icon as showing in below image

Configuring Static IP on Ubuntu 22.04

  • A new Wired dialog box will appear.
  • Now, click on “IPv4” tab.
  • Set IPv4 Method to Manual
  • Input a valid IP address, Netmark and Gateway address
  • Set the DNS server (optional)
  • Click Apply button to save changes

Configuring Static IP on Ubuntu 22.04

  • All done. Ubuntu Desktop system IP address is now changed.

Method 2: Configuring Static IPv4 Address on Ubuntu 22.04 Server with CLI

Server editions are installed without any graphical interface. In that case, you need to configure the IP address using the command line.

Ubuntu uses the Netplan as a network manager that is responsible for configuring the network interfaces. Follow the below steps:

Configure Static IPv4 Address using Netplan on Ubuntu

Add the network configuration in YAML format as below:

In the above configuration:

  • eth0 - is the network interface name
  • addresses - is used to configure IPv4 address on an interface. Make sure to define CIDR. You can add multiple addresses here
  • nameservers - Set the name servers here. 8.8.8.8 and 8.8.4.4 are Google's name servers
  • routes - This is used to set gateway on your system.

In this tutorial, you have learned 2 methods of configuring network interface on Ubuntu 22.04 systems. The first method uses the GUI interface to set up a static IP address. The second method provides you with the instructions to configure the network interface via the command line using Netplan.

You can also configure multiple IP addresses on a single network interface.

Related Posts

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

How to Setup DKIM (DomainKeys) with Postfix

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

How to Install Composer on Ubuntu 22.04

How to Install and Use Composer on Ubuntu 22.04

10 comments.

assign ip in ubuntu

**networkctl list** IDX LINK TYPE OPERATIONAL SETUP 1 Io loopback carrier unmanaged 2 eth0 ether routable configured

**route** Destination Gateway Genmask ….. iface default 192.168.178.1 0.0.0.0 …… eth0 192.168.178.0 0.0.0.0 255.255.255.0 …… eth0

**/etc/netplan/000-installer-config.yaml** network: version: 2 renderer: networkd ethernets: eth0: addresses: – 192.168.178.43/24 nameservers: addresses: [8.8.8.8] routes: – to: default via: 192.168.178.1

After this `ip-a` confirms i have ip address 192.168.178.43, but `ping -4 192.168.178.1` says: Destination Host Unreachable

Any ideas on how to change? I only have CLI, no GUI running

assign ip in ubuntu

Oh man bring back /etc/network/interfaces

assign ip in ubuntu

If you use the GUI, you need to disable and then enable the connection. Just clicking on ‘Apply’ doesn’t change anything.

assign ip in ubuntu

I am getting an error: Error in network definition expected mapping (check indentation) network:

Any help would be great!

assign ip in ubuntu

When I set – to: default via: 192.168.1.1 I get an error : could not find expected ‘-‘ before via and when I add this ‘-‘ before via, then I get : error in network definition: global unicst route must include both ‘to’ and ‘via’ IP.

That’s a nightmarre to configure a simple eth0 using CLI.

assign ip in ubuntu

I have again verified the configuration file and it works fine for me. Make sure that JSON is properly formatted and any extra or less space may cause syntax issues.

assign ip in ubuntu

It is warning that gateway4 is depracated and default routes should be used instead.

Thanks, Ken, article is updated accordingly.

assign ip in ubuntu

gateway4: is no longer allowed as an option in Ubuntu 22.04

Now requires

routes: – to: default via: 192.168.1.1

Thanks, Passerby, gateway4 works but as its deprecated, I have updated the article to routes.

Leave A Reply Cancel Reply

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

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

How-To Geek

How to use the ip command on linux.

It is time to break up with ifconfig.

Quick Links

How the ip command works, using ip with addresses, display only ipv4 or ipv6 addresses, display information for a single interface, adding an ip address, deleting an ip address, using ip with network interfaces, starting and stopping links, using ip with routes, display information for a single route, adding a route, taken route, not taken root, key takeaways.

  • The ip command has replaced the older ifconfig command in modern versions of Linux.
  • The ip command allows you to configure IP addresses, network interfaces, and routing rules on the fly without rebooting.
  • Run "ip addr" in the Terminal to get your PC's local IP address.

You can configure IP addresses, network interfaces, and routing rules on the fly with the Linux ip command. We'll show you how you can use this modern replacement of the classic (and now deprecated) ifconfig .

With the ip command, you can adjust the way a Linux computer handles IP addresses, network interfaces controllers (NICs), and routing rules . The changes also take immediate effect — you don't have to reboot. The ip command can do a lot more than this, but we'll focus on the most common uses in this article.

The ip command has many subcommands, each of which works on a type of object, such as IP addresses and routes. There are, in turn, many options for each of these objects. It's this richness of functionality that gives the ip command the granularity you need to perform what can be delicate tasks. This isn't ax work — it calls for a set of scalpels.

We'll look at the following objects:

  • Address : IP addresses and ranges.
  • Link : Network interfaces, such as wired connections and Wi-Fi adapters.
  • Route : The rules that manage the routing of traffic sent to addresses via interfaces ( links ).

Obviously, you first have to know the settings you're dealing with. To discover which IP addresses your computer has, you use the ip command with the object address . The default action is show , which lists the IP addresses. You can also omit show and abbreviate address as "addr" or even "a."

The following commands are all equivalent:

ip address show

ip addr show

ip address show in a terminal window

We see two IP addresses, along with a lot of other information. IP addresses are associated with network interface controllers (NICs). The ip command tries to be helpful and provides a bunch of information about the interface, too.

The first IP address is the (internal) loopback address used to communicate within the computer. The second is the actual (external) IP address the computer has on the local area network (LAN).

Let's break down all the information we received:

  • lo : The network interface name as a string.
  • <LOOPBACK,UP,LOWER_UP>: This is a loopback interface. It's UP , meaning it's operational. The physical networking layer (layer one) is also up.
  • mtu 65536: The maximum transfer unit. This is the size of the largest chunk of data this interface can transmit.
  • qdisc noqueue: A qdisc is a queuing mechanism. It schedules the transmission of packets. There are different queuing techniques called disciplines. The noqueue discipline means "send instantly, don't queue." This is the default qdisc discipline for virtual devices, such as the loopback address.
  • state UNKNOWN: This can be DOWN (the network interface is not operational), UNKNOWN (the network interface is operational but nothing is connected), or UP (the network is operational and there is a connection).
  • group default: Interfaces can be grouped logically. The default is to place them all in a group called "default."
  • qlen 1000: The maximum length of the transmission queue.
  • link/loopback: The media access control (MAC) address of the interface.
  • inet 127.0.0.1/8: The IP version 4 address. The part of the address after the forward-slash ( / ) is Classless Inter-Domain Routing notation (CIDR) representing the subnet mask. It indicates how many leading contiguous bits are set to one in the subnet mask. The value of eight means eight bits. Eight bits set to one represents 255 in binary, so the subnet mask is 255.0.0.0.
  • scope host: The IP address scope. This IP address is only valid inside the computer (the "host").
  • lo: The interface with which this IP address is associated.
  • valid_lft: Valid lifetime. For an IP version 4 IP address allocated by Dynamic Host Configuration Protocol (DHCP), this is the length of time the IP address is considered valid and able to make and accept connection requests.
  • preferred_lft: Preferred lifetime. For an IP version 4 IP address allocated by DHCP, this is the amount of time the IP address can be used with no restrictions. This should never be larger than the valid_lft value.
  • inet6 : The IP version 6 address, scope , valid_lft , and preferred_lft .

The physical interface is more interesting, as we'll show below:

  • enp0s3: The network interface name as a string. The "en" stands for ethernet, "p0" is the bus number of the ethernet card, and "s3" is the slot number.
  • <BROADCAST,MULTICAST,UP,LOWER_UP>: This interface supports broad- and multicasting , and the interface is UP (operational and connected). The hardware layer of the network (layer one) is also UP .
  • mtu 1500: The maximum transfer unit this interface supports.
  • qdisc fq_codel: The scheduler is using a discipline called "Fair Queuing, Controlled Delay." It's designed to provide a fair share of the bandwidth to all the traffic flows that use the queue.
  • state UP: The interface is operational and connected.
  • group default: This interface is in the "default" interface group.
  • link/ether: The MAC address of the interface.
  • inet 192.168.4.26/24: The IP version 4 address. The "/24" tells us there are 24 contiguous leading bits set to one in the subnet mask. That's three groups of eight bits. An eight-bit binary number equates to 255; therefore, the subnet mask is 255.255.255.0.
  • brd 192.168.4.255: The broadcast address for this subnet.
  • scope global: The IP address is valid everywhere on this network.
  • dynamic: The IP address is lost when the interface goes down.
  • noprefixroute: Do not create a route in the route table when this IP address is added. Someone has to add a route manually if he wants to use one with this IP address. Likewise, if this IP address is deleted, don't look for a route to delete.
  • enp0s3: The interface with which this IP address is associated.
  • valid_lft: Valid lifetime. The time the IP address will be considered valid; 86,240 seconds is 23 hours and 57 minutes.
  • preferred_lft: Preferred lifetime. The time the IP address will operate without any restrictions.
  • inet6: The IP version 6 address, scope , valid_lft , and preferred_lft .

If you want to limit the output to the IP version 4 addresses, you can use the -4 option, as follows:

ip -4 addr in a terminal window

If you want to limit the output to the IP version 6 addresses, you can use the -6 option, as follows:

ip -6 addr in a terminal window

If you want to see the IP address information for a single interface, you can use the show and dev options, and name the interface, as shown below:

ip addr show dev lo

ip addr show dev enp0s3

ip addr show dev lo in a terminal window

You can also use the -4 or -6 flag to further refine the output so you only see that in which you're interested.

If you want to see the IP version 4 information related to the addresses on interface enp0s3 , type the following command:

ip -4 addr show dev enp0s3

ip -4 addr show dev enp0s3 in a terminal window

You can use the add and dev options to add an IP address to an interface. You just have to tell the ip command which IP address to add, and to which interface to add it.

We're going to add the IP address 192.168.4.44 to the enp0s3 interface. We also have to provide the CIDR notation for the subnet mask.

We type the following:

sudo ip addr add 192.168.4.44/24 dev enp0s3

sudo ip addr add 192.168.4.44/24 dev enp0s3 in a terminal window

We type the following to take another look at the IP version 4 IP addresses on this interface:

ip -4 addr show dev enp0s3 in a terminal window

The new IP address is present on this network interface. We jump on another computer and use the following command to see if we can ping the new IP address :

ping 192.168.4.44

ping 192.168.4.44  in a terminal window

The IP address responds and sends back acknowledgments to the pings. Our new IP address is up and running after one simple ip command.

To delete an IP address, the command is almost the same as the one to add one, except you replace add with del , as shown below:

sudo ip addr del 192.168.4.44/24 dev enp0s3

sudo ip addr del 192.168.4.44/24 dev enp0s3 in a terminal window

If we type the following to check, we see the new IP address has been deleted:

ip -4 addr show dev enp0s3 in a terminal window

You use the link object to inspect and work with network interfaces. Type the following command to see the interfaces installed on your computer:

ip link show

ip link show: in a terminal window

To see a single network interface, just add its name to the command, as shown below:

ip link show enp0s3

ip link show enp0s3 in a terminal window

You can use the set option with either up or down to stop or start a network interface option. You also have to use sudo , as shown below:

sudo ip link set enp0s3 down

sudo ip link set enp0s3 down in a terminal window

We type the following to take a look at the network interface:

ip link show enp0s3 in a terminal window

The state of the network interface is DOWN . We can use the up option to restart a network interface, as shown below:

sudo ip link set enp0s3 up

sudo ip link set enp0s3 up in a terminal window

We type the following to do another quick check on the state of the network interface:

ip link show enp0s3 in a terminal window

The network interface was restarted, and the state is shown as UP .

With the route object, you can inspect and manipulate routes. Routes define to where network traffic to different IP addresses is forwarded, and through which network interface.

If the destination computer or device shares a network with the sending computer, the sending computer can forward the packet directly to it.

However, if the destination device is not directly connected, the sending computer forwards the packet to the default router. The router then decides where to send the packet.

To see the routes defined on your computer, type the following command:

ip route in a terminal window

Let's take a look at the info we received:

  • default: The default rule. This route is used if none of the other rules match what's being sent.
  • via 192.168.4.1: Routes the packets via the device at 192.168.4.1. This is the IP address of the default router on this network.
  • dev enp0s3: Use this network interface to send the packets to the router.
  • proto dhcp: The routing protocol identifier. DHCP means the routes will be determined dynamically.
  • metric 100: An indication of the preference of the route compared to others. Routes with lower metrics are preferentially used over those with higher metrics. You can use this to give preference to a wired network interface over a Wi-Fi one.

The second route governs traffic to the IP range of 169.254.0.0/16. This is a zero-configuration network , which means it tries to self-configure for intranet communication. However, you can't use it to send packets outside the immediate network.

The principle behind zero-configuration networks is they don't rely on DHCP and other services being present and active. They only need to see TCP/IP in order to self-identify to each of the other devices on the network.

Let's take a look:

  • 169.254.0.0/16: The range of IP addresses this routing rule governs. If the computer communicates on this IP range, this rule cuts in.
  • dev enp0s3: The network interface the traffic governed by this route will use.
  • scope link : The scope is link , which means the scope is limited to the network to which this computer is directly connected.
  • metric 1000 : This is a high metric and isn't a preferred route.

The third route governs traffic to the IP address range of 192.168.4.0/24. This is the IP address range of the local network to which this computer is connected. It's for communication across, but within, that network.

Let's break it down:

  • 192.168.4.1/24: The range of IP addresses this routing rule governs. If the computer communicates within this IP range, this rule triggers and controls the packet routing.
  • dev enp0s3: The interface through which this route will send packets.
  • proto kernel: The route created by the kernel during auto-configuration.
  • scope link: The scope is link , which means the scope is limited to the immediate network to which this computer is connected.
  • src 192.168.4.26: The IP address from which packets sent by this route originate.
  • metric 100: This low metric indicates a preferred route.

If you want to focus on the details of a particular route, you can add the list option and IP address range of the route to the command as follows:

ip route list 192.168.4.0/24

ip route list 192.168.4.0/24 in a terminal window

We just added a new network interface card to this computer. We type the following and see it's showing up as enp0s8 :

ip link show in a terminal window

We'll add a new route to the computer to use this new interface. First, we type the following to associate an IP address with the interface:

sudo ip addr add 192.168.121.1/24 dev enp0s8

sudo ip addr add 192.168.121.1/24 dev enp0s8 in a terminal window

A default route using the existing IP address is added to the new interface. We use the delete option, as shown below, to delete the route and provide its details:

sudo ip route delete default via 192.168.4.1 dev enp0s8

sudo ip route delete default via 192.168.4.1 dev enp0s8 in a terminal window

We'll now use the add option to add our new route. The new interface will handle network traffic in the 192.168.121.0/24 IP address range. We'll give it a metric of 100; because it will be the only route handling this traffic, the metric is pretty much academic.

sudo ip route add 192.168.121.0/24 dev enp0s8 metric 100

sudo ip route add 192.168.121.0/24 dev enp0s8 metric 100 in a terminal window

Now, we type the following to see what it gives us:

ip route in a terminal window

Our new route is now in place. However, we still have the 192.168.4.0/24 route that points to interface enp0s8 — we type the following to remove it:

sudo ip route delete 192.168.4.0/24 dev enp0s8

sudo ip route delete 192.168.4.0/24 dev enp0s8 in a terminal window

We should now have a new route that points all traffic destined for IP range 192.168.121.0/24 through interface enp0s8 . It should also be the only route that uses our new interface.

We type the following to confirm:

ip route in a terminal window

The great thing about these commands is they're not permanent. If you want to clear them, just reboot your system. This means you can experiment with them until they work the way you want. And it's a very good thing if you make a terrible mess of your system — a simple reboot will restore order.

On the other hand, if you want the changes to be permanent, you have to do some more work. Exactly what varies depending on the distribution family, but they all involve changing config files.

This way, though, you can test-drive commands before you make anything permanent.

How to Set Static IP Address on Ubuntu Server 22.04

In this post, we will cover how to set static ip address on Ubuntu server 22.04.

It is highly recommended to have a static ip on linux server because it would be persistent across the reboot. Static IP plays an important role for servers like Mail Server, Web Server and File server etc.

Prerequisites

  • Minimal Installed Ubuntu Server 22.04
  • Regular User with sudo admin rights

In Ubuntu server 22.04, networking is controlled by netplan utility , so we will use netplan to configure static ip address on Ubuntu server.

Note: we cannot use nmcli utiltity as it is not the part of default installation on Ubuntu server.

Setting up Static IP address on Ubuntu Server 22.04

Login to your Ubuntu server 22.04, look for the netplan configuration file. It is located under /etc/netplan directory.

Run below cat command to view the contents of ‘00-installer-config.yaml’

Note: Name of configuration file may differ as your per setup. As it is an yaml file, so make sure to maintain the indentation and syntax while editing.

Default-Content-netplan-ubuntu-server

As per above output, it says that we have ens33 interface and it is getting ip from dhcp server. Alternate way to view interface name is via ip command.

Now, to configure static ip in place of dhcp, edit netplan configuration file using vi or nano editor and add the following content.

save and close the file.

Updated-Netplan-Config-File-Content-Ubuntu-Server

In the above file we have used following,

  • ens33 is the interface name
  • addresses are used to set the static ip
  • nameservers used to specify the DNS server ips
  • routes used to specify the default gateway

Note: Change the IP details and interface name as per your environment.

To make above changes into the effect the apply these changes using following netplan command,

Run following ip command to view the ip address on interface,

To view the default route, run

Output of above commands,

ip-addr-route-command-output-ubuntu-server

Perfect, above commands’ output confirms that static ip and route has been configured successfully.

That’s all from this post. Kindly do post your queries and feedback in below comments section.

11 thoughts on “How to Set Static IP Address on Ubuntu Server 22.04”

How do I use Netplan to set up a static IP address on WIFI?

change the network device “ens33” to something else, it will be listed when you run “ip a”; it;s probably wlan0 but that’s not guaranteed.

there will be a config file for the wifi interface. look for something like 00-installer-config-wifi.yaml

Hey! thanks I had problems before setting up the DNS and none config would work! This one did and you made this post really simple to follow!

Your text for configuring a static IP address does not work in my Ubuntu 20.04.5 server’s NIC. No matter how I space or tab the indentations, I get “Ivalid YAML: inconsistent indentation: addresses:

I’ve been at the problem for a couple of weeks, with no fix in site; no spacing or tabbing change I make fixes it. Can anyone please advise me? Thanks.

try paste the YAML into here ‘https://www.yamllint.com/’

Copy paste not work here, you should try typing instead or if you paste, try to delete all the space before each line and tab key until the same format

The spacing must be done with the space key. If you try to make spaces in a yaml file with the tab key it will not work. Also you should let yamllint.com correct the file for you

Your article is quite nice and clear! but after followed, following error occurred when ping google.com: “temporary failure in name resolution”, meanwhile localhost can be visited. Is anyone facing this issue as well? I’ll quite appreciate it if can get some advise.

can we use default DHCP ip configuration along with another static ip in ubuntu 22.04 ? i already have ens33 then i added eth0 as static ip , netplan apply did not thrown any errors but unable to see my static ip , when i do ifconfig 🙁 even after reboot its not applying, any suggestions..

i successfully set up my static ip but I cant ping to 192.168.1.1 why

Leave a Comment Cancel reply

XDA Developers

How to set a static internal IP in Ubuntu

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

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

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

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

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

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

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

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

Setting complete

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

How to set a static internal IP in Ubuntu

IMAGES

  1. Assign multiple IP address to Ubuntu 20.04 single network interface- GUI

    assign ip in ubuntu

  2. How to configure an IP range on Ubuntu 16/18

    assign ip in ubuntu

  3. Find out how to Configure Static IP Handle on Ubuntu 20.04

    assign ip in ubuntu

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

    assign ip in ubuntu

  5. Assign multiple IP address to Ubuntu 20.04 single network interface- GUI

    assign ip in ubuntu

  6. How to Set a Static IP Address On Ubuntu 22.04

    assign ip in ubuntu

VIDEO

  1. Assign Static and Dynamic IP address on Ubuntu Server

  2. How to assign Static IP Address in Ubuntu 17.04

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

  4. How To Configure Static IP in Ubuntu 18.04 Desktop

  5. 10.0.2.15 Ip address problem in ubuntu linux fixed

  6. How to install vmware tools in Windows virtual machine to get full screen

COMMENTS

  1. How to Configure Static IP Address on Ubuntu 20.04

    Typically, in most network configurations, the IP address is assigned dynamically by the router DHCP server. Setting a static IP address may be required in different situations, such as configuring port forwarding or running a media server . Configuring Static IP address using DHCP

  2. How to Set a Static IP Address 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. Set static IP in Ubuntu using Command Line

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

  4. How to Assign Static IP Address on Ubuntu Linux

    Method 1: Assign static IP in Ubuntu using command line Note for desktop users: Use static IP only when you need it. Automatic IP saves you a lot of headache in handling network configuration. Step 1: Get the name of network interface and the default gateway

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

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

    Configure a Static IP Address with Netplan on Ubuntu 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.

  8. How to Configure Static IP Address on Ubuntu 20.04

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

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

    Login to your desktop environment and click on network icon and then choose wired settings. In the next window, Click on ' gear box ' icon under wired option, In the next window, Choose IPV4 Tab and then select Manual and specify the IP details like IP address, netmask, gateway and DNS Server IP.

  10. networking

    Get the IP address from the server using: sudo dhclient eth0; Assign the first ip addresses like this: sudo ip addr add 192.168.20.222/24 dev eth0, and repeat for other IP addresses. Add the default route using: sudo route add default gw <internet gateway ip address> If you do step 2, step 4 is not required. Hope that helps.

  11. How to assign static IP address on Ubuntu Linux

    To assign a static IP address on Ubuntu (server or client) through the Settings app, use these steps: Open Settings. Click on Network. Click the Settings button for the "Wired" network interface. Click the IPv4 tab. Select the Manual option for the "IPv4 Method" setting.

  12. How to Set Static IP Address on Ubuntu Linux

    Firstly, run the command below to change into the netplan directory and then list the contents of the netplan directory as follows. $ sudo cd /etc/netplan $ ls You should see the default Netplan configuration file. Mine is named 01-network-manager-all.yaml on my Ubuntu 20.04 machine.

  13. Change IP address on Ubuntu Server

    You have two options when configuring the IP address on your Ubuntu Server, and that is either a static IP address or DHCP.

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

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

  15. How to Set a Static IP Address On Ubuntu 22.04

    1. Using GNOME Network Manager Using the GNOME network control center to set a static IP address on In Ubuntu 22.04 desktop is straightforward. Set IP for Wired Interface using GNOME

  16. How To Configure Static IP Address In Ubuntu (Easy Guide)

    Assigning a static IP in Ubuntu and its derivatives can be done using both graphical and command-line tools such as netplan, nmcli, and nmtui etc. First, we will discuss the netplan method. Method 1 - Configure Static IP Address via Netplan Configuration File Netplan is a utility for easily configuring networking on a Ubuntu Linux system.

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

    Method 2: Use Netplan YAML network configuration. On Ubuntu 22.04|20.04|18.04, you can use Netplan which is a YAML network configuration tool to set static IP address. This configuration assumes your network interface is called eth0. This may vary depending on your working environment. Create a network configuration file.

  18. How To Assign an IP Address in Ubuntu Server 20.04.3 Using Command Line

    Quick Answer. To assign an IP address in Ubuntu Server 20.04.3 using the command line, you can use the Netplan configuration utility. Open the Netplan configuration file, modify the network interface settings to specify a static IP address, gateway, and DNS servers, save the changes, and apply the new configuration using the sudo netplan apply ...

  19. How to Configure Static IP Address on Ubuntu 22.04

    Follow the below steps to configure a static IP address on Ubuntu 22.04 Desktop system. Click the network icon in the upper-right corner. Then expand the Wired Connected dropdown. Now, click on Wired Setting as shown below image. A network settings dialog box will appear. Now, click "Network" in left sidebar.

  20. Configuring networks

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

  21. How to Use the ip Command on Linux

    Adding a Route Taken Route, Not Taken Root Key Takeaways The ip command has replaced the older ifconfig command in modern versions of Linux. The ip command allows you to configure IP addresses, network interfaces, and routing rules on the fly without rebooting. Run "ip addr" in the Terminal to get your PC's local IP address.

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

    Setting up Static IP address on Ubuntu Server 22.04. Login to your Ubuntu server 22.04, look for the netplan configuration file. It is located under /etc/netplan directory. Run below cat command to view the contents of '00-installer-config.yaml'. Note: Name of configuration file may differ as your per setup. As it is an yaml file, so make ...

  23. How to set a static internal IP in Ubuntu

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