Wednesday, November 23, 2016

Configure Static IP On CentOS 6



Below steps will show configuration to set static IP address in Cent-OS machine.

    Network configuration files are under "/etc/sysconfig/network-scripts".
    We can open the file with editor like nano, vi, vim etc...
   
    Here I will use vi editor.
   
    In this server we will set Static IP for eth0 Ethernet port

1 - Start your server running Cent-OS enter root user credentials and login.

2 - Type the command,

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

    This will open network configuration file, edit below lines:

         NM_CONTROLLED=yes
         ONBOOT=yes
         TYPE=Ethernet
         BOOTPROTO=static
         IPADDR=192.168.1.44            # Replace IP with your new
         NETMASK=255.255.255.0     # Replace IP with your subnet mask

3 - Type the command,

         vi /etc/sysconfig/network
   
    This will open file to set default gateway, edit below lines:

         NETWORKING=yes
         GATEWAY=192.168.1.1        # Replace IP with your gateway IP

4 - Type the command,

          vi /etc/resolv.conf
   
    This will open file to set DNS,

          nameserver 8.8.8.8                # Replace IP with your DNS IP
          nameserver 192.168.1.1        # Replace IP with your DNS IP

5 - To apply changes restart network interface, Type the command.
   
          /etc/init.d/network restart
   
NOTE:
Some time you might face issue in accessing your system. It can be due to firewall.
       
        To stop firewall temporary execute command,

            service iptables stop
           
        To stop firewall permanently execute command,

            service iptables stop
            chkconfig iptables off
           

 
ENJOY! and Stay connected.

0 comments :

Post a Comment