Tecmint: Linux Howtos, Tutorials & Guides

How to Set Static IP Address and Configure Network in Linux

If you are a Linux system administrator, time will come when you will need to configure networking on your system. Unlike desktop machines where you can use dynamic IP addresses, on a server infrastructure, you will need to setup a static IP address (at least in most cases).

Read Also: How to Set or Change System Hostname in Linux </p

This article is meant to show you how to configure static IP address on most frequently used Linux distributions.

For the purpose of this tutorial, we will use the following Internet Protocol version 4 (IPv4) details:

Configure Static IP Address in RHEL/CentOS/Fedora:

To configure static IP address in  RHEL / CentOS / Fedora , you will need to edit:

Where in the above "ifcfg-eth0" answers to your network interface eth0 . If your interface is named “ eth1" then the file that you will need to edit is "ifcfg-eth1" .

Let’s start with the first file:

Open that file and set:

Note : Make sure to open the file corresponding to your network interface. You can find your network interface name with ifconfig -a command .

In that file make the following changes:

You will only need to edit the settings for:

  • DNS1 and DNS2

Other settings should have already been predefined.

Next edit resolve.conf file by opening it with a text editor such as nano or vi :

Once you have made your changes restart the networking with:

Set Static IP Address in Debian / Ubuntu

To setup static IP address in Debian / Ubuntu , open the following file:

You may see a line looking like this:

Change it so it looks like this:

Save the file and then edit /etc/resolv.conf like this:

Restart the networking on your system with:

Your static IP address has been configured.

Conclusion:

You now know how to configure a static IP address on a Linux distro. If you have any questions or comments, please do not hesitate to submit them in the comment section below.

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

Extract Linux Tar Files Different or New Directory

How to Extract Tar Files to Specific or Different Directory in Linux

Debian Goodies Utilities to Manage Debian Packakges

8 Useful ‘Debian Goodies Utilities’ for Package Management

Delete User Accounts with Home Directory in Linux

How to Delete User Accounts and Their Home Directories in Linux

Find and Kill Running Processes in Linux

How to Find and Kill Running Processes in Linux

Set System Time, Date and Timezone in Linux

How to Set Time, Timezone and Synchronize System Clock in Linux

FFMPEG Command Examples in Linux

15 Must-Know FFmpeg Commands for Video, Audio & Image Conversion

32 thoughts on “How to Set Static IP Address and Configure Network in Linux”

The time will come when you will need to configure networking on your system. Unlike desktop machines where you can use dynamic IP addresses, on a server infrastructure, you will need to set up a static IP address (at least in most cases).

Terrible – and my ‘ linux distro ‘ isn’t the same as yours, there’s no ‘ /etc/sysconfig/ ‘ folder.

In Ubuntu 20.04 there is no interfaces file they switch to netplan . If you can update this article to include the new change it will help a lot.

thanks Raouf

Well, this isn’t correct. Just trashed my Linux mint distro

Is it public Static IP? or can I use to access data from other networks?

Failed to restart network.service: Unit network.service not found.

I’m asking a question on a fairly old thread, but just in case, is it possible to do this on a WIFI network?

For example, when using the first command (# nano /etc/network/interfaces ) in Ubuntu, the result I see is:

There isn’t an “ eth0 ” on my server because it is connected by WIFI only. Will it still work using another option?

Yes it will work I think so, just change the settings in the interfaces file as explained in this article.

I set the static IP in ifcfg-eth0, added HWADDR and UUID, but on reboot system does not associate the IP to eth0.

This is VM. Any idea why its happening and steps to troubleshoot.

I think you need to make sure that you select “ manual ” and the correct IP address, subnet mask, and gateway and save the configuration as explained in the article. Also, I personally would select a new and different IP address, so that you can really check if it has been saved by opening the terminal and typing:

after a restart.

If i set ip address as static am not able to ping google.com why and also packages are not installed.

Please give me reply as soon as possible.

@Rajeshkar,

Please add the DNS Name servers in your /etc/resolv.conf file..

@Ravi Saive thanks for your reply , yes i did /etc.resolv.conf also but getting the same problem

@Rajesekar,

The file is /etc/resolv.conf , in this file add your DNS name servers for example.

When I enter the /etc/resolv.conf file, what is it supposed to look like? And when you say “edit” do you mean delete what’s there and write what you’ve provided, or just add new lines?

Hello Marin, Thank you very much for this article. It was a major help in my class project. This is my first time using a vm and it is an awesome learning experience. I’m really glad I ran into this article, it was well written and easy to follow.

Just wanted to say a million thank you’s for this well-written, comprehensive and easily-understood article! Awesome stuff! A real lifesaver too, as I had to quickly configure a static IP for myself to get access to remote computing. Thank you! :-D

A question from a linux newbie. Does this instruction apply for both ubuntu running on my desktop PC as well as debian linux on an embedded board?

Yes, the instructions will works on any Debian/Ubuntu based distribution without any issues..have you tried on your embedded board? does these instructions worked? let us know.

Hi Ravi, thanks for your reply.

Default the folder /etc/sysconfig does not exist on my embedded system. Of Course i could create it as well as the files mentioned, but it would be out of the context of this instructions.

Thanks, Rob

I found here very good stuff! You are doing an excellent job and I like your site! Thanks!

Thanks for finding this site very useful and thanks for appreciating our work, Keep visiting for more such useful articles…

Great job, I was I actually looking for an article like this one. So thank you so very much. Keep up the good work.

Thanks for appreciating and finding this article useful, keep connected to Tecmint for such wonderful articles…:)

What if I have 2 NICs on my server one for LAN & one for WAN and I want to set one of them (WAN) as default gateway? How to configure this server as gateway and as a router.

The easiest way to add default gateway using route command as shown:

Don’t forget to replace the gateway IP address and interface-name in the above command.

One can also use following command to setup static IP on eth0 interface for example. # ifconfig eth0 192.168.1.1 netmask 255.255.255.0 up # route add default gw 192.168.0.1 # service network restart

Thanks for the tip, but I think setting IP address directly from the commandline using ifconfig and route will only allow you to set temporarily, once you reboot, these settings disappears. So, the best option to set static IP address permanently in network configuration files only….

wipe on reboot, so that best option is to set permannetly

Hello Ravi, What is difference between the service “NetworkManager” and “network”

@Augustine,

This article will help you to understand the difference between and NetworkManager and Network: http://askubuntu.com/questions/1786/what-is-the-difference-between-network-manager-and-ifconfig-ifup-etc

Why do we need to specify DNS in both ifcfg-eth0 and resolvlf.conf?

Hello Augustine,

Actually if you have added the DNS servers in the ifcfig-eth0 file the DNS servers will be automatically added to /etc/resolv.conf. You can skip defining the DNS servers in the ifcfig-eth0 file, but then you will need to have them set in /etc/resolv.conf manually. It’s a good practice to make sure that the DNS servers are specified correctly in both files, this is why the article says to set them in both files.

Got something to say? Join the discussion. Cancel reply

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

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

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

How-To Geek

How to set a static ip address in ubuntu.

When static is the way forward.

Quick Links

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

After gathering your connection name, subnet mask, and default gateway, you can set a static IP address in the terminal using the nmcli command. Or, in the GNOME desktop, open your connection settings and click the + icon, then enter the info for your static IP address there.

Your home network relies on IP addresses to route data between devices, and sometimes on reconnecting to the network a device's address can change. Here's how to give an Ubuntu Linux computer a permanent IP address that survives reboots.

Everything on your network home network, whether it's using a wired connection or Wi-Fi, has an IP address . IP stands for Internet Protocol. An IP address is a sequence of four numbers separated by three dots. Each IP address that is unique within that network.

IP addresses act as numeric labels. Your router uses these labels to send data between the correct devices. Usually, your router assigns IP addresses. It knows which IP addresses are in use and which are free. When a new device connects to the network, it requests an IP address and the router allocates one of the unused IP addresses. This is called DHCP, or dynamic host configuration protocol .

When a device is restarted or powered off and on, it may receive its old IP address once more, or it might be allocated a new IP address. This is normal for DHCP and it doesn't affect the normal running of your network. But if you have a server or some other computer that you need to be able to reach by its IP address, you'll run into problems if its IP address doesn't survive power downs or reboots.

Pinning a specific IP address to a computer is called allocating a static IP address . A static IP address, as its name suggests, isn't dynamic and it doesn't change even if the computer is power-cycled .

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

We're demonstrating this technique on Ubuntu 22.04 LTS, but it ought to work on any Linux distribution, including Ubuntu 23.04. The nmcli tool was released in 2004, so it should be present on just about any standard distribution.

Let's take a look at the network connections that already exist on the computer. We're using the connection command with the show argument.

nmcli connection show

Using nmcli to list network connections

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

The details of a single network connection displayed by nmcli

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

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

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

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

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

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

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

ping 192.168.86.128

Using ping to determine if an IP address is in use

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

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

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

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

The first command is a long one.

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

Creating a new connection with the nmcli command

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

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

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

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

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

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

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

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

Using the nmcli command to set an IP address to static

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

nmcli con up "static-ip" ifname enp0s3

Using the nmcli command to start a network connection

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

nmcli con show

The details of two network connections displayed by nmcli

Here's the output:

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

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

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

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

The system menu with the

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

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

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

Giving a name to a new connection profile in the

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

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

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

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

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

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

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

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

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

The IPv4 tab of the connection settings dialog

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

Using the nmcli command or the GNOME desktop and apps, you can hop between network connections very easily and very quickly.

It's more convenient to have a selection of connection profiles and move between them as you need to, rather than to have one that you keep editing. If something goes horribly wrong with the connection you're editing or adding, you can always fall back on one of the existing connections.

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

Stack Exchange Network

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

Q&A for work

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

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

I'm trying to set up a lab computer as a ssh server following this guide . One of the steps is setting up a static IP address. So, I was glad to find this answer . Following it, I created /etc/netplan/50-cloud-init.yaml file, pasted

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

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

Screenshot

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

--EDIT from 12/05/2021--

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

01-network-manager-all.yaml:

50-cloud-init.yaml:

99_config.yaml:

  • network-manager

Serg's user avatar

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

Pick ONE of the following two configurations...

Server installation with static IP...

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

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

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

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

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

sudo netplan generate

sudo netplan apply

Desktop installation with static IP...

Delete /etc/netplan/99_config.yaml

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

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

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

heynnema's user avatar

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

You must log in to answer this question.

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

  • The Overflow Blog
  • Exploring the inclusive tech revolution sponsored post
  • 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...

Hot Network Questions

  • SF story about sharing tools and other possesions with RFID tags
  • Isomorphic finite fields of a skew field
  • What is the technical definition of "clone" that makes the K1810VM88 (К1810ВМ88) not a clone of the 8088?
  • What is causing this impossibly long return time in AC Brotherhood on the PS3?
  • How to apply outlines to edges of faces in a mesh?
  • Nicer expression for 2.1369288...?
  • How to account for the difference between the sexes in a mortality rate
  • Reading the motto of Obispado de Cuenca
  • Which heptomino is it obvious can't tile the plane?
  • Advisor's Move to Another University: Should I Identify as a Visiting Student or Visiting Researcher?
  • BJT B-E Zenering: whither the collector?
  • Movie about a team of people drilling to the center of the Earth to save humanity
  • A complicated sorting problem
  • What's the word similar to jittery in spelling or pronunciation, but means some privately-run transportation by small vehicles?
  • If the tidal bulge on the earth speeds the moon up, how does the moon move to a higher orbit?
  • Brainfuck to C transpiler
  • Why are Alkali atoms used in many Cold Atom experiments?
  • What is the word for the feeling when the piano key catches at the bottom of a press. The word for when the jack slips
  • Cayley Table Sudoku
  • Sonic Boom Location
  • How to create an alphanumerical Hash string with fixed length?
  • Does psychophysical harmony strongly point toward theism?
  • How can the ECtHR judgement on encryption be reconciled with the UK's Online Safety act?
  • How to identify the keys to power in a government?

linux assign static ip

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.

linux assign static ip

How to configure a static IP on Linux

By default, upon installation, any Linux system uses DHCP  for its network configuration. This implies that it automatically obtains an IP address from a router or a DHCP server in a network.  However, there are certain instances that require configuration of a static IP.  A good example is where you have a server, e.g a web server or an  FTP server. You definitely don’t want its IP to keep changing once the DHCP lease time is over. This will definitely cause loss of service once the IP changes.

Let’s see how we can configure a static IP  in different distros.

Configuring a static IP in Fedora 27, CentOS and RHEL 7

Firstly, list the IP of all interfaces

Sample Output

Above, we can observe that our IP address is 192.168.43.160 and netmask is 255.255.255.0 We are going to configure this statically.

Navigate to the following path to view interface statistics of interface enp0s3

The sample output should contain the following parameters:

This tells the system to start networking service at boot time.

To set a static IP, modify the following settings:

Restart the networking service

Verify the settings.

Also, check the nameservers

using nmtui utility

nmtui, short for Network Manager Text User interface is a GUI tool that painlessly allows you to configure your network interface without having to touch the command line. It can be installed both on RPM and Debian based distributions.

For Centos & RHEL 7

Launching nmtui

nmtui static IP

Select an interface to configure

nmtui-2 static IP

Press ‘Tab’ key to navigate to the other options. Hit edit.

nmtui-3 static IP

Navigate to IPV4 and select ‘show’

nmtui-4 static IP config

Hit Okay. Go back and select Quit

nmtui-quit static IP

Finally, restart networking service.

Configuring a static IP in Ubuntu 14.04, 16.04

Navigate to the network interface configuration file

DHCP settings

To configure a static IP, remove DHCP and append ‘static’ to ‘inet’ and enter your preferred address, netmask, gateway and dns-name servers

Restart networking

Verify the settings using ifconfig command and cat /etc/resolv.conf

Wrapping up

Your thoughts about this article are highly welcome. Feel free to get back to us for any clarifications.

' src=

About James

Related articles.

  • How to fix the repository is not signed error on Ubuntu 20.04
  • How to Create Additional FTP Accounts on VestaCP
  • How to restrict SSH access only to specific IPs
  • LAMP on CentOS 6

linux assign static ip

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

linux assign static ip

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.

linux assign static ip

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

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

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

  • Assign a static IP address
  • Edit on GitHub

Assign a static IP address ¶

This guide explains how to assign a static IP address. This may be helpful in scenarios such as a network with no DHCP server.

Identify which program is managing the interface

Using NetworkManager

Using systemd-networkd

Identify which program is managing the interface ¶

New installations of Clear Linux* OS use NetworkManager as the default network interface manager for all network connections.

The cloud Clear Linux OS images continue to use systemd-networkd to manage network connections.

In earlier Clear Linux OS versions, systemd-network was used to manage Ethernet interfaces and NetworkManager was used for wireless interfaces.

Before defining a configuration for assigning a static IP address, verify which program is managing the network interface.

Check the output of nmcli device to see if NetworkManager is managing the device.

If the STATE column for the device shows connected or disconnected , the network configuration is being managed by NetworkManager, then use the instructions for using NetworkManager .

If the STATE column for the device shows unmanaged , then check if the device is being managed by systemd-networkd.

Check the output of networkctl list to see if systemd-networkd is managing the device.

If the SETUP column for the device shows configured , the network configuration is being managed by systemd-networkd , then use the instructions for using systemd-networkd .

Using NetworkManager ¶

Network connections managed by NetworkManager are stored as files with the .nmconnection file extension in the /etc/NetworkManager/system-connections/ directory.

A few tools exists to aid to manipulate network connections managed by NetworkManager:

nmcli - a command-line tool

nmtui - a text user interface that provides a pseudo graphical menu in the terminal

nm-connection-editor - a graphical user interface

The method below uses the command line tool nmcli to modify network connection.

Identify the existing connection name:

Sample output:

If a connection does not exist, create it with the nmcli connection add command.

Modify the connection to use a static IP address. Replace the variables in brackets with the appropriate values. Replace [CONNECTION_NAME] with the NAME from the command above.

See the nmcli developer page for more configuration options. For advanced configurations, the /etc/NetworkManager/system-connections/*.nmconnection . can be edited directly.

Restart the NetworkManager server to reload the DNS servers:

Verify your static IP address details have been set:

Using systemd-networkd ¶

Network connections managed by systemd-networkd are stored as files with the .network file extension the /etc/systemd/network/ directory.

Files to manipulate network connections managed by systemd-networkd must be created manually.

Create the /etc/systemd/network directory if it does not already exist:

Create a .network file and add the following content. Replace the variables in brackets with the appropriate values. Replace [INTERFACE_NAME] with LINK from the output of the networkctl list command that was run previously.

See the systemd-network man page for more configuration options.

Restart the systemd-networkd service:

*Other names and brands may be claimed as the property of others.

  • *Trademarks
  • Privacy Terms

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. How to Configure Static IP on Linux Debian

    linux assign static ip

  2. How To Configure Static IP Address In Linux And Unix

    linux assign static ip

  3. How to Assign Static IP Address on Ubuntu Linux

    linux assign static ip

  4. How to Set Static IP Address on Ubuntu 22.04

    linux assign static ip

  5. How to Set a Static IP in Kali Linux Using the GUI and ifconfig?

    linux assign static ip

  6. How To Set A Static IP Address On A Network Interface In Linux

    linux assign static ip

VIDEO

  1. Assign Static IPs for A Network

  2. How to assign Static IP Address in Ubuntu 17.04

  3. Assign Static and Dynamic IP address on Ubuntu Server

  4. How To Configure Static Ip In dlink Router

  5. How to Assign a Static IP Address in Windows 10 and Windows 11

  6. how to assign static ip address in kali linux

COMMENTS

  1. How to Set Static IP Address and Configure Network in Linux

    How to Set Static IP Address and Configure Network in Linux Marin Todorov Last Updated: July 13, 2023 Linux Commands 32 Comments If you are a Linux system administrator, time will come when you will need to configure networking on your system.

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

    Manual Network Configuration in Linux and How to Set a Static IP Address Last updated: January 22, 2024 Written by: Hiks Gerganov Administration Networking ip systemctl 1. Introduction Many Linux distributions come with a network manager. In theory, it should help during the networking setup.

  3. How to Set a Static IP Address in Ubuntu

    Or, in the GNOME desktop, open your connection settings and click the + icon, then enter the info for your static IP address there. Your home network relies on IP addresses to route data between devices, and sometimes on reconnecting to the network a device's address can change.

  4. Setting up static IP address for Linux: Easier than you think

    Add or modify the configuration below : BOOTPROTO=static IPADDR=192.168..1 NETMASK=255.255.255. GATEWAY=192.168..1 DNS1=8.8.8.8 DNS2=8.8.4.4

  5. How to set up static IP address on Debian Linux 10/11

    Open the terminal application. Log in to remote or server using ssh command. Backup /etc/network/interfaces file running sudo cp /etc/network/interfaces /root/ Edit the /etc/network/interfaces Configure static IP address for enp0s5 Ethernet interface: address 192.168.2.249 Add subnet mask: netmask 255.255.255.

  6. How to Configure Static IP Address on Ubuntu 20.04

    The first step toward setting up a static IP address is identifying the name of the ethernet interface you want to configure. To do so, use the ip link command, as shown below: ip link The command prints a list of all the available network interfaces. In this example, the name of the interface is ens3:

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

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

  9. How To Configure Static IP Address In Linux And Unix

    Table of Contents 1. Configure Static IP Address In Linux 1.1. Assign Static IP address In Fedora, RHEL, CentOS, AlmaLinux, Rocky Linux 1.1.1. Set Static IP Address By Editing Network Configuration File 1.1.2. Set IP Address Using Nmtui 1.1.3. Set IP Address Using Nmcli 1.2. Configure Static IP Address In Debian, Ubuntu 1.2.1.

  10. How to Assign Static IP Address on Ubuntu Linux

    Method 2: Switch to static IP address in Ubuntu graphically. If you are on desktop, using the graphical method is easier and faster. Go to the settings and look for network settings. Click the gear symbol adjacent to your network connection. Next, you should go to the IPv4 tab.

  11. How to configure a static IP on Linux

    How to configure a static IP on Linux 21890 views 1 min , 50 sec read 12 By default, upon installation, any Linux system uses DHCP for its network configuration. This implies that it automatically obtains an IP address from a router or a DHCP server in a network. However, there are certain instances that require configuration of a static IP.

  12. Linux Static IP Address Configuration

    For static IP configuration you need to edit the following files using a text editor such as vi. Edit /etc/sysconfig/network as follows, enter: # cat /etc/sysconfig/network. Sample static ip configuration: NETWORKING=yes HOSTNAME=server1.cyberciti.biz GATEWAY=192.168.1.254.

  13. How to Set a Static IP Address in Linux

    Configuring a static IP can be difficult in Linux because it's different based on the distro and version you're using. This guide will show you how to configure a static IP address on the most popular Linux distros. Ubuntu. As of version 17 of Ubuntu, networking is configured using Netplan, which is a YAML-based configuration system. ...

  14. How to configure a static IP address on RHEL 8 / CentOS 8 Linux

    In this tutorial we learn how to set a static IP address for a network interface in RHEL 8 / CentOS 8. We show three methods to perform said action: by manually editing a connection file, by using the nmcli command line utility, and finally by using nmtui, a text-user interface.

  15. Linux Basics

    Ubuntu 12.04 - 17.04 (incl. Ubuntu 16.04 LTS) Step 1: Configure the network interface. Step 2: Configure the DNS servers. Step 3: Restart networking. Configure the Hostname. This tutorial explains how to set up a static IP address on an Ubuntu system from the command line. It covers network configuration for all current versions of Ubuntu and ...

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

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

    Verify the New Static IP Address; Conclusion. Setting a static IP address on Ubuntu 24.04 involves identifying the correct network interface, editing the Netplan configuration file with the new IP settings, securing the file permissions, and applying the changes. This process ensures your server can communicate consistently and securely on your ...

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

  19. 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. Under the "Addresses" section, confirm the static IP address ...

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

  21. How to setup a Static IP address on Debian Linux

    The first option is to add IP address configuration directly into /etc/network/interfaces file. Append the following line to your existing /etc/network/interfaces: address 10.1.1.125 netmask 255.0.0.0 gateway 10.1.1.1 The resulting content /etc/network/interfaces file should look like the one below.

  22. Assign a static IP address

    Sample output: NAME UUID TYPE DEVICE Wired connection 1 00000000 -0000-0000-0000-000000000000 802 -3-etherneten01. Copy to clipboard. If a connection does not exist, create it with the nmcli connection add command. Modify the connection to use a static IP address. Replace the variables in brackets with the appropriate values.

  23. configure linux box to have a static ip

    Let you Linux box on dhcp. Log on to router setting page. There should be a setting page to assign static ip to a given MAC address. This is available on Linksys router. If your doesn't support than see if you can flash your router with dd-wrt/open-wrt/tomato. these firmware definatly support this feature.

  24. How to configure static IP address on Alpine Linux

    Every bit helps. Join Patreon Configuring Static IP address on Alpine server We define DHCP or static configuration in /etc/network/interfaces file. The first entry must be a loopback (lo0) interface. For example, we can use the cat command: cat /etc/network/interfaces auto lo iface lo inet loopback My Ethernet device name is eth0.

  25. How to set a static internal IP in Ubuntu

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

  26. How to Add Static Entries to the Hosts File on Linux

    For example, to map the "example.com" domain to the IP address "10.0.1.69," the final version should look like this: Mapping a domain name to the IP address in the "/etc/hosts" file on Linux. After adding your entries, save the changes and exit the editor. Now, it's time to test your changes.

  27. Get Dedicated IP with VPN for Business

    Yes, fixed IP (or static) addresses are safe. A VPN with fixed IP is individual to you and your company, utilizing a dedicated server that handles your traffic only. Both shared and private IPs will keep your identity confidential, and both IP address types are equally safe.