Tag Archives: interface

Set static IP on CentOS 6 via command line

Here is how to configure a static IP on CentOS 6 via command line.

  1. Determine which interface you want to configure--in this example, I will be using eth0
    1. ifconfig -a
    2. Show all linux interfaces
  2. Edit the interface you wish to configure (I'll use nano as vi requires some knowledge for beginner Linux users)
    1. nano /etc/sysconfig/network-scripts/ifcfg-eth0
    2. nano ifcfg-eth0
  3. Use the following settings and then use Control+O to Save and Control+X to Exit
    1. nano /etc/sysconfig/network-scripts/ifcfg-eth0
    2. DHCPCLASS=
      IPADDR=192.168.1.100
      NETMASK=255.255.255.0
      ONBOOT=yes
      BOOTPROTO=STATIC
    3. static IP CentOS
  4. Next, let's configure the hostname and default gateway.  We will use nano again to edit the file.
    1. nano /etc/sysconfig/network
    2. Ensure GATEWAY=192.168.1.1 has been set
    3. Static Gateway
  5. Next, let's configure our DNS servers to resolve domain names (in this case, I will set mine to use Google's DNS servers)
    1. nano /etc/resolv.conf
    2. nameserver 8.8.8.8
      nameserver 8.8.4.4
    3. static nameservers
  6. Restart the networking service for the changes to take effect
    1. /etc/init.d/network restart
    2. restart interface