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

linux configure static ip address

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 configure static ip address

FOSS Linux

@2023 - All Right Reserved.

How to configure static IP address on Linux Mint

configure static ip address on linux mint

B y default, your system relies on DHCP, a dynamic host control protocol whose purpose is to assign you an IP address automatically. As a result, each device is assigned a unique number that enables it to communicate with other networks using DHCP, and as an outcome, your device’s IP address may change from time to time.

However, there are situations when a static IP address is required, and it is essential to maintain a similar IP address for an extended time. For instance, if you set up your system as a server, static IP addresses are required for communication. If you want users to download files from your computer, you must ensure that your machine’s IP address never changes. Additionally, a static IP address is required if you wish to connect to any external shared device, such as a printer.

Configuring static IP address on Linux Mint

Three methods are available for configuring a static IP address:

  • Configuration via a graphical user interface
  • Configuration through the use of a terminal
  • Configuration via modifying a network configuration file

Configuring static IP address using GUI

Static IP configuration on your Linux mint OS is pretty straightforward using this technique. First, pick network settings from the menu and click on the network icon, as seen below.

network

After navigating to the network settings, you’ll notice the basic information about your currently created network and the IP address issued via DHCP. Thus, by clicking on the settings tab on the bottom, you can modify that to a static IP address.

static ip configuration

Static IP configuration

Now you must change the address from “automatic (DHCP)” to “Manual.”

automatic dhcp

Automatic DHCP

After choosing the manual option, you will be prompted to enter the desired network settings, as illustrated below. You must enter the values and click the apply button afterward to save the changes. The static IP address would be 192.168.114.100; the gateway and network mask would be configured.

ipv4 manual configuration

IPv4 Manual configuration

You must return to the network settings’ main window to view the freshly implemented settings.

network configuration

Network configuration

Configuring static IP address using the terminal

You can configure static IP addresses via the command-line interface (CLI). To do so, execute the following command:

This will open up a new window with various options; you must click the first one, “Edit a Connection,” to implement the new settings shown below.

edit a connection

Edit a connection

The following step is to change the “IPv4 CONFIGURATION” setting from automatic to manual and enter the essential info to make it work.

manual

We used the identical network variables as in our first example.

edit connection

Edit connection

Now, save these changes, return to the main screen, and choose the second option from the list below.

activate a connection

Activate a connection

The first option allows you to modify your network settings, while the second option, “Activate the connection,” applies those modifications. You must open it, click the “Deactivate” button, and click “Activate” again to restart your network and apply the new settings.

deactivate

Therefore, if you want to verify that the updated network parameters have been applied, you can run the following command in the terminal.

Verify network settings

Verify network settings

As you can see in the above screenshot, the freshly assigned IP address is currently live and functional, as indicated by the “ens33” field, a network interface containing IPv4 information.

Configuring static IP address on Linux Mint via a network configuration file

You can also set static IP addresses by making changes to the network configuration file; to do so, open the file with your preferred editor:

We’re using a nano editor in the above command, and after loading this file, you’ll need to enter a few lines specified below and then save the file.

nano add commands copy

Nano add commands

You should now be able to view your newly configured network settings, which you can confirm by typing this command again:

Configuration file

Configuration file

Additionally, you can verify whether or not the new route parameters have been implemented by typing:

  • How to install FTP Server on Linux Mint

15 cool things to do in Linux Mint

  • How to create or add a SWAP partition in Ubuntu and Linux Mint

New route

By default, your Linux Mint OS is configured to use DHCP, which means that the IP address assigned to your machine may change dynamically to a different available IP address. However, there are situations when a static IP address is required, such as connecting with a server. This is where static IP comes into play; it prevents your IP address from changing frequently and will remain the same unless it is changed by another party or restored to DHCP. I hope this article was helpful. If yes, please leave a remark below. Thanks for reading.

You may also like

My linux journey: why i always choose linux..., how to install and try different linux kernels..., how to launch chrome with a keyboard shortcut..., top 20 linux mint keyboard shortcuts for beginners, complete guide to installing a lamp server on....

'  data-srcset=

nice job – helped me a lot

Leave a Comment Cancel Reply

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

fl_logo_v3_footer

ENHANCE YOUR LINUX EXPERIENCE.

FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

MORE FROM US

  • Ubuntu (309)
  • Downloads (245)
  • Learn Linux (242)
  • Beginner's Guide (179)
  • Terminal Tuts (167)
  • Featured (125)
  • Linux Mint (98)
  • Server (95)
  • Fedora (80)
  • Privacy Policy
  • Terms of Use
  • GDPR Policy
  • Linux Careers

A PART OF VIBRANT LEAF MEDIA COMPANY.

“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.

  • Beginner’s Guide
  • Terminal Tuts
  • Learn Linux

How to Configure Static IP Address on Fedora Linux

Hi techies, as we know Fedora is one of popular open source Linux based operating system. Fedora Linux can be used as workstation, Server, and CoreOS.

In this guide, we learn how to manually configure static ip address on Fedora Linux (Fedora 36 Workstation). A static IP address is an IP address that stays the same over time and remain persistent across the reboot. There are two different ways to configure static IP.

  • nmcli utility (Command Line)
  • Graphically

Configure Static IP address on Fedora 36 Using nmcli

The nmcli is a command line utility and used to configure a static IP address on Fedora Linux. To use this command, you must first open a terminal window (Ctrl+Alt+T). Then, you will need to type in the following commands:

This will show you a list of all the connections that are currently configured on your system.

nmcli-connection-show-fedora-linux

In my case, my Fedora system is connected to modem and got the IP from DHCP server. Now to make the IP address static and persistent, run following nmcli commands.

Following commands will modify the existing connection name ‘ Wired Connection 1 ’

Run beneath command to add static ip address along with the gateway ip.

To add DNS IP address, run

To make above changes into the effect, disable and enable the connection,

Verify the ip address using ip command ,

Output of above commands would like below,

nmcli-static-ip-fedora-linux

In case, you don’t want to use the existing connection and want to create new connection for configuring the static IP address, run following commands one after the another,

Assign Static IP Address on Fedora 36 via Graphically

Note: For this method to work, make sure desktop environment is installed on your fedora system.

Login to the desktop environment, go to Settings and then choose Network

Network-From-Settings-Fedora-Linux

Click on gearbox icon ,

In following window, Choose IPv4 ,

IPv4-Method-Graphically-Fedora-Linux

Choose ‘ Manual ’ to assign static ip address, gateway and DNS IP.

Specify details as below:

  • IP address: 192.168.1.189
  • Netmask: 255.255.255.0
  • Gateway IP: 192.168.1.1
  • DNS IP: 192.168.1.1

Note: Replace the IP details as per your environment.

Static-IP-address-Manual-Fedora-GUI

Click on Apply .

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

Close the window and open the terminal and run ip command to verify the ip address.

Verift-Static-IP-Address-Fedora-Linux

Prefect, above commands output confirm that static IP address has been configured successfully on our Fedora Linux.

That’s all from this guide. In case you have found it informative, so please do share it among your technical friends.

1 thought on “How to Configure Static IP Address on Fedora Linux”

super, thanks of lot.

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

GoLinuxCloud

Set Static IP in Rocky Linux [6 Different Methods]

Different methods to set static ip address - rocky linux 8.

After a successful installation of Rocky Linux on your environment , there is need to configure network. You can either configure a static or a dynamic IP address. Network connections in Rocky Linux are managed by NetworkManager daemon.

In this guide, we shall discuss how to configure IP addresses on Rocky Linux using the different methods available.

There are many ways to configure IP addresses on Rocky Linux. In this guide, we shall cover the following:

  • Configuring IP address through manually editing the network interface file.
  • Configure IP address using ifconfig utility
  • Using ip utility
  • Using ifcfg utility
  • Configuring IP using the NMTUI tool
  • Configuring IP address using NMCLI tool

Method-1: Manually Edit Network Interface Config File

The first method that we shall discuss is where you edit a configuration file for a specific network interface to set the IP address and other options such as the DNS server.

To do this, you first need to identify the available network interfaces. Run the command below to identify the available interfaces.

Set Static IP in Rocky Linux [6 Different Methods]

In the above output, I have four interfaces:

  • Loopback interface (lo)

This information is important as you need to know the interface name, and most importantly the MAC address of the interface that you intend to configure.

It is also important to get the status of the NetworkManager service:

The network interface configuration files exist at /etc/sysconfig/network-scripts/ . The interface configuration files have the prefix ifcfg-<interfacce>

You can list the contents of the directory to identify the interface configuration files under /etc/sysconfig/network-scripts/ as shown:

Assuming we want to update or add or modify the IP address of the interface enp0s3 , we shall edit the file ifcfg-enp0s3 .

In the above configuration file, the following are the most important fields to take note of:

  • TYPE - The interface type, such as Ethernet
  • BOOTPROTO - This is the IP configuration method(Static/DHCP). Use "static" for a static IP or "dhcp" for a DHCP configuration.
  • ONBOOT - allows the interface to come up when the machine reboots
  • HWADDR - The MAC address of the interface
  • DEFROUTE - specify if the interface will be used for the default route.
  • NAME - The name of the interface, such as enp0s3
  • DEVICE - The physical NIC name (obtained from "ip addr" command)
  • IPADDR - The IP address that you intend to assign the interface
  • PREFIX - The Subnet mask prefix, such as 24, 27, etc.
  • GATEWAY -  the gateway for the IP address assigned
  • DNS - The DNS IP for the DNS server

Manually update these fields in the respective interface configuration file and save the changes. To activate the configuration, run the command below:

Method-2: Configure Static IP Address using ifconfig

You can also configure a static IP address on Rocky Linux using the ifconfig tool.

The syntax to configure IP Address using ifconfig tool would be:

For example to assign static IP address to enp0s8 interface, execute the following command:

Next in case this interface is the default interface, you would also need to provide the default gateway. To assign a default gateway to your interface, execute the following command:

In the above command, we have set the IP for the interface enp0s8 and also created a default route to pass through the same interface.

Method-3: Configure Static IP using ip command

We can also configure IP using the ip command provided by the iproute2 package. To get the general information of your network configuration on Rocky Linux, use the command below:

You can assign a static IP to an interface using following syntax:

For example to assign static IP to ens0p8 interface, we use following command:

Check the interface details after applying the above command:

You can then bring down and then bring up the interface to activate the changes:

To add the gateway:

Method-4: Configure Static IP using ifcfg Utility

Configure a static IP on Rocky Linux 8 using the ifcfg utility as shown below:

The above command adds the IP 172.29.10.10/24 to the interface enp0s8.

You can remove the IP address on the interface by  the command below:

Use the following command to check the default routes:

Method-5: Set Static IP Address using NMTUI

NMTUI is the acronym of Network Manager Terminal User Interface . This means that you can manage the network using an interface presented through the terminal. To use this tool, you need to have some packages installed.

To edit a network connection, run the command below as root user or with sudo privilege:

You will see a screen like this below:

Set Static IP in Rocky Linux [6 Different Methods]

Select the " Edit a connection " option to edit a network interface. You will then need to choose the interface that you wish to edit in the subsequent screen.

Set Static IP in Rocky Linux [6 Different Methods]

Under IPv4 Configuration , hit the Enter key to bring the drop down menu and select Manual . Here, you are required to configure the IP configuration of the interface as desired.

Set Static IP in Rocky Linux [6 Different Methods]

Set the IPv4 configuration to either Automatic or Manual if you want DHCP or Static IP configuration respectively.

Put the IP address at the " Addresses " section, remember to append the subnet mask of the IP. Such as 192.168.100.149/24 where /24 is the subnet mask prefix.

Add the Gateway for the IP and the DNS servers.

To have the interface always connected (after reboot), check the " Automatically connect " option. It is also advisable to check the " Available to all users " option unless you have a reason not to.

Finish the configuration by pressing " OK " at the bottom. Head back to the first screen to activate the connection.

Set Static IP in Rocky Linux [6 Different Methods]

Choose the " Activate a connection " option to activate the specific interface that we have configured in the previous step.

Choose the interface then select the " Activate " button on the right.

Set Static IP in Rocky Linux [6 Different Methods]

You can now exit and verify that the interface has come up.

You can also use nmtui to set the system hostname.

To achieve this, run the nmtui command once more and select the set system hostname option.

Set Static IP in Rocky Linux [6 Different Methods]

Set the hostname in the space provided then press " OK "

Set Static IP in Rocky Linux [6 Different Methods]

You will receive a prompt that the hostname configuration has been successful.

Set Static IP in Rocky Linux [6 Different Methods]

Verify the hostname by running the command below:

Method-6: Set Static IP Address using NMCLI on Rocky Linux

NMCLI is an acronym for Network Manager Command Line Interface . Just like NMTUI, NMCLI is a command-line NetworkManager configuration tool.

This tool can also be used to configure the network interfaces just like the two methods we have discussed above.

To configure the interfaces, we first of all need to check and see the available configurations.

You can also use the nmcli device show command to see a more detailed picture of your network configuration.

To configure manual network configuration for an interface using NMCLI, follow the interface below:

The above command sets the IP 172.29.10.10/24 to the interface enp0s8 .

You can also add the Gateway and DNS settings as below:

Finally, set the IP for the interface to manual:

You can also use the nmcli shell to edit interface configuration for a specific interface.

You will be presented with an interface such as this below:

You can run commands such as describe interface and also add the IP configuration from this shell.

Save the configuration for the settings to take effect.

Verify the IP configuration

In this tutorial we covered different methods to configure static IP Address in Rocky Linux using different tools and commands. The network configuration done using ip, ifcfg and ifconfig tool are non-persistent which means the changes are temporary and are valid only for the current session. If someone restarts the network service then your changes will be overwritten. Or if someone reboots the server then also the changes will be overwritten with the default configuration.

So if you are looking to set static IP address persistently across reboot then you should choose nmcli, nmtui or manually updating the network configuration file.

Further Reading

Rocky Linux Network Configuration

Set Static IP in Rocky Linux [6 Different Methods]

He is the founder of GoLinuxCloud and brings over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, AWS, Networking, and Security. With extensive experience, he excels in various domains, from development to DevOps, Networking, and Security, ensuring robust and efficient solutions for diverse projects.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to [email protected]

Thank You for your support!!

Leave a Comment Cancel reply

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

Notify me via e-mail if anyone answers my comment.

IMAGES

  1. How to Configure Static IP Address on Linux System

    linux configure static ip address

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

    linux configure static ip address

  3. How to Configure Static IP on Linux Debian

    linux configure static ip address

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

    linux configure static ip address

  5. How to Configure Static IP Address on Ubuntu 20.04

    linux configure static ip address

  6. Linux Basics

    linux configure static ip address

VIDEO

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

  2. Configure Static IP address on Windows Server Machine

  3. CSS NCII TUTORIAL PART1

  4. configure static ip address in kali linux

  5. How To Configure Static Ip In dlink Router

  6. Ethical HACKING Lesson

COMMENTS

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

    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.

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

    To configure static IP address in RHEL / CentOS / Fedora, you will need to edit: /etc/sysconfig/network /etc/sysconfig/network-scripts/ifcfg-eth0 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:

  3. How to Set a Static IP Address in Ubuntu

    Quick Links What Is a Static IP Address? Setting a Static IP in Ubuntu Set a Static IP in Ubuntu with the GUI Connection Convenience Key Takeaways After gathering your connection name, subnet mask, and default gateway, you can set a static IP address in the terminal using the nmcli command.

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

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

    To edit the configuration, use this command: $ vi /etc/sysconfig/network-scripts/ifcfg-eth0 Note: Here eth0 is the network card name, and it can be different for different computers. 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

  6. Setting a Static IP in Ubuntu

    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

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

    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. Set Static IP Address In Debian 1.2.2.

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

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

    Configure Static IP address on Server In this example we will set a static IP address on the Ubuntu 20.04 server to 192.168.1.202/24 with default gateway to 192.168.1.1 and DNS servers 8.8.8.8 8.8.4.4 192.168.1.1. Locate and edit with administrative privileges the /etc/netplan/50-cloud-init.yaml file with the following configuration.

  10. How to Configure Static IP Address on Ubuntu 18.04

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

  11. Netplan static IP on Ubuntu configuration

    A static IP address allows you to manually select your IP address by configuring it on the Linux system, whereas DHCP relies on the router or DHCP server to lease you an IP address - either a reserved one or the next available one that is currently free, depending on the setup. In this tutorial you will learn how to:

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

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

    5.5K. Setting up a static IP address in Ubuntu Linux is a common task for system administrators and advanced users. This guide will explore various ways to configure a static IP address in Ubuntu 22.04 LTS operating system.. 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.

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

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

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

  17. How to configure static IP address on Linux Mint

    Configuring static IP address using the terminal. You can configure static IP addresses via the command-line interface (CLI). To do so, execute the following command: nmtui. This will open up a new window with various options; you must click the first one, "Edit a Connection," to implement the new settings shown below. Edit a connection.

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

  19. How To Configure Static And Dynamic IP Address In Arch Linux

    Method 1: Assign Static IP Address in Arch Linux using netctl Method 2: Set Static IP Address in Arch Linux using systemd Configure Dynamic IP Address In Arch Linux using Netctl Configure Static IP Address in Arch Linux We can configure static IP address in two methods. We will see both. Method 1: Assign Static IP Address in Arch Linux using netctl

  20. How to Configure Static IP Address on Fedora Linux

    Login to the desktop environment, go to Settings and then choose Network. Click on gearbox icon, In following window, Choose IPv4, Choose ' Manual ' to assign static ip address, gateway and DNS IP. Specify details as below: IP address: 192.168.1.189. Netmask: 255.255.255..

  21. How to configure static IP address on Alpine Linux

    IPv4 static address configuration for Alpine Linux version 3.13.xx. Let us set static IP address to 192.168.2.16 with 255.255.255. (/24) subnet. The default gateway set to 192.168.2.254 and Alpine Linux hostname set to nixcraft-x140e: auto eth0 iface eth0 inet static address 192.168.2.16/ 24 gateway 192.168.2.254 hostname nixcraft-x140e.

  22. How to set a static internal IP in Ubuntu

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

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

    The purpose of this tutorial is to configure a static IP address on Ubuntu 22.04 Jammy Jellyfish Linux. When it comes to IP addresses on Ubuntu 22.04, you have two main options for how you configure your network interfaces.You can either obtain an IP address automatically with DHCP, or configure the system to use a static IP address, which never changes.

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

  25. Different methods to set Static IP Address

    Method-1: Manually Edit Network Interface Config File Method-2: Configure Static IP Address using ifconfig Method-3: Configure Static IP using ip command Method-4: Configure Static IP using ifcfg Utility Method-5: Set Static IP Address using NMTUI Method-6: Set Static IP Address using NMCLI on Rocky Linux Conclusion Further Reading