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:

IP address:
Domain name:
DNS Server 1:
DNS Server 2:

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:

# vi /etc/sysconfig/network

Open that file and set:


Next open:

# vi /etc/sysconfig/network-scripts/ifcfg-eth0

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:

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

# vi /etc/resolv.conf
nameserver # Replace with your nameserver ip
nameserver # Replace with your nameserver ip

Once you have made your changes restart the networking with:

# /etc/init.d/network restart  [On SysVinit]
# systemctl restart network    [On SystemD]

Set Static IP Address in Debian / Ubuntu

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

# nano /etc/network/interfaces

You may see a line looking like this:

auto eth0
iface eth0 inet dhcp

Change it so it looks like this:

auto eth0
iface eth0 inet static 

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

# nano /etc/resolv.conf
nameserver # Replace with your nameserver ip
nameserver # Replace with your nameserver ip

Restart the networking on your system with:

# /etc/init.d/network restart  [On SysVinit]
# systemctl restart network    [On SystemD]

Your static IP address has been configured.


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.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Marin Todorov

I am a bachelor in computer science and a Linux Foundation Certified System Administrator. Currently working as a Senior Technical support in the hosting industry. In my free time I like testing new software and inline skating.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide
The Complete Linux System Administrator Bundle
Become an Ethical Hacker Bonus Bundle

You may also like...

29 Responses

  1. dburke8088 says:

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

  2. Rana Raheel Tariq says:

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

  3. Ben says:
    # systemctl restart network

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

  4. Matthew S. says:

    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:

    "# interfaces(5) file used by ifup(8) and ifdown(8)
    auto lo
    iface lo inet loopback"

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

    • Ravi Saive says:


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

  5. Rashmi Ranjan says:


    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.


    • Joh Smith says:

      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:

      $ ifconfig

      after a restart.

Leave a Reply to dburke8088 Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.