How to Configure Static IP Address on CentOS 6.2 Linux Server

In server administration, configuring a static IP address on your CentOS 6.2 Linux server is a fundamental skill.

This guide will walk you through the process step-by-step, ensuring you understand each part of the process. This tutorial is designed for those who have already installed CentOS 6.2 on their server.

Upon the completion of your CentOS 6.2 installation, your network configuration will look something like this:


This configuration means that your system will not automatically acquire an IP address, and the network interface will not auto-start even after the server is rebooted. This guide will show you how to set a static IP and configure it to auto-start upon reboot.

Step 1: Configure eth0

The first step is to configure your network interface, eth0. Open the network scripts for eth0 by typing the following command into your terminal:

[root@centos6 ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

In the opened file, set the following parameters:


This configuration sets your network interface (eth0) to start automatically upon boot (ONBOOT=”yes”) and assigns it a static IP address (IPADDR= with a netmask of

Step 2: Configure Default Gateway

The next step is to configure your default gateway. Open the network configuration file by typing the following command into your terminal:

[root@centos6 ~]# vi /etc/sysconfig/network

In the opened file, set the following parameters:


This configuration enables networking (NETWORKING=yes), sets your hostname (HOSTNAME=centos6.2), and defines your default gateway (GATEWAY=

See also  How to Configure Bind Chroot DNS Server on Linux CentOS 5.7 Server

Step 3: Restart Network Interface

After configuring your network interface and default gateway, you need to restart your network interface for the changes to take effect. You can do this by typing one of the following commands into your terminal:

[root@centos6 ~]# /etc/init.d/network restart


[root@centos6 ~]# Service network restart

Step 4: Configure DNS Server

The final step is to configure your DNS server. Open the resolv.conf file by typing the following command intoyour terminal:

[root@centos6 ~]# vi /etc/resolv.conf

In the opened file, set the following parameters:


This configuration sets your primary DNS server to (Google’s public DNS server) and your secondary DNS server to (usually your router’s IP address).

Commands Mentioned

  • vi /etc/sysconfig/network-scripts/ifcfg-eth0 – Opens the network scripts for the eth0 interface
  • vi /etc/sysconfig/network – Opens the network configuration file
  • /etc/init.d/network restart – Restarts the network interface
  • Service network restart – An alternative command to restart the network interface
  • vi /etc/resolv.conf – Opens the DNS configuration file
See also  How to Install Nginx on CentOS 7 / RHEL 7


Configuring a static IP address on your CentOS 6.2 Linux server is a crucial step in setting up your server for optimal performance. By following this guide, you’ve learned how to configure your network interface, set a static IP address, configure your default gateway, and set up your DNS servers. Remember, understanding each step of the process is key to successful server administration.

Whether you’re running a dedicated server, a VPS server, or utilizing cloud hosting or shared hosting, having a firm grasp on these fundamental skills will serve you well. Keep exploring, keep learning, and keep pushing the boundaries of what you can do with your server.


  1. What is a static IP address?

    A static IP address is a fixed IP address that is manually assigned to a device on a network. Unlike dynamic IP addresses, which are assigned by a DHCP server and can change over time, static IP addresses remain constant.

  2. Why would I need to configure a static IP address on my server?

    Configuring a static IP address on your server ensures that the IP address remains constant, even after a reboot. This is crucial for services that require a consistent IP address, such as DNS servers, mail servers, or websites.

  3. What is the purpose of the “ONBOOT” parameter in the network configuration?

    The “ONBOOT” parameter in the network configuration determines whether the network interface should be activated at boot time. If set to “yes”, the network interface will automatically start upon system boot.

  4. What is a DNS server and why do I need to configure it?

    A DNS (Domain Name System) server translates domain names into IP addresses. This allows users to access websites by typing in the domain name instead of the IP address. Configuring a DNS server ensures your server can resolve domain names correctly.

  5. What is the difference between a primary and secondary DNS server?

    The primary DNS server is the first server your computer will query to resolve a domain name into an IP address. If the primary DNS server is unavailable or cannot provide the requested information, your computer will query the secondary DNS server.



  • Avatar vol123 says:

    Exellent!!! Thanks alot )

  • Avatar Xplorer4x4 says:

    Thank you for the useful guide. Much appreciated! However, if I may make a suggestion. Usually I use nano, but it seems it is not built in to CentOS6.X so I was not familiar with Vim and assumed CTRL+X would work. May I suggest a quick mention of using ESC then typing :X and hit enter?

Leave a Reply

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