How to Set Static IP Address and Configure Network in Linux

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

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Use our Linode referral link if you plan to buy VPS (it starts at only $10/month).
  4. Support us via PayPal donate - Make a Donation
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

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.

Receive Your Free Complimentary eBook NOW! -

Download Free Linux eBooks

Advanced Bash-Scripting Guide
Linux Bible
A Newbie's Getting Started Guide to Linux
Introduction to Linux - A Hands on Guide

You may also like...

16 Responses

  1. Kath says:

    Hi Marin!

    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

  2. Rob van Schelven says:

    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?

    • Ravi Saive says:

      @Rob,

      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.

      • Rob van Schelven says:

        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

  3. Ice Alinutza says:

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

    • Ravi Saive says:

      @Ice,

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

  4. Alex says:

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

    • Ravi Saive says:

      @Alex,

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

  5. Rahul says:

    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.

    • Ravi Saive says:

      @Rahul,

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

      # route add default gw 192.168.0.1 eth0
      

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

  6. Vikas says:

    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

  7. Augustine says:

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

    • Marin Todorov says:

      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.

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

Join Over 150K+ Linux Users
  1. 100,756
  2. 5,113
  3. 36,418

Enter your email to get latest Linux Howto's