You have a Linux computer or server and want to set up the IP address on the box? If so, this tutorial may be for you.
The tutorial tries to cover most popular Linux used by people. The configuration via command line interface should be the same with all major Linuxes, the different thing may be located on the configuration files. Different Linux distribution has different configuration files stored in the system.
Basically when you firstly installed a Linux OS, they offer a DHCP (dynamic host configuration protocol) for the IP address (usually on the Ethernet card). Once you plug the ethernet cable to the ethernet port, the IP address will be automatically assigned by a DHCP server located in your office / home. This is the easiest thing to assign the IP address for the ethernet interface. You don’t need to manually assign it with an IP address. This tutorial shows you how to manually assign IP address on the ethernet interface.
The first basic setting up IP address manually is via command line interface. Using root / super user account, type the command below in the command shell (assuming eth0 as the ethernet interface and on 192.168.10.0/24 IP network).
ifconfig eth0 192.168.10.10 netmask 255.255.255.0
Don’t forget to add a default route / gateway to the interface so you can access other IP networks (internet).
route add default gw 192.168.10.1
To be able to access internet, you need at least DNS server IP address to map domain name to IP address. You can use your office DNS server or use the free Public Google DNS (IP address: 220.127.116.11 and 18.104.22.168) or OpenDNS (IP address: 22.214.171.124 and 126.96.36.199). The DNS IP addresses stored in /etc/resolv.conf. Here is the inside of /etc/resolv.conf file should look like:
nameserver 188.8.131.52 nameserver 184.108.40.206
The configuration set up via command line interface above is a temporary configuration. Once the system restarted, the configuration will disappear. So you need to type again multiple time you restart the computer. To avoid this, I will show you how to make it permanent by saving it in the configuration files. It differs on every Linux distribution. I will try to cover the major of it.
In Slackware, the network interface configuration file is located in /etc/rc.d/rc.inet1.conf. For the above configuration (configured via command line above), this file should contain like below:
# Config information for eth0: IPADDR="192.168.10.10" NETMASK="255.255.255.0" USE_DHCP="" DHCP_HOSTNAME=""
Note that number inside the ‘’ is the network interface number. That means,  is for eth0,  is for eth1 and so on.
Below that codes, there is a gateway configuration option.
# Default gateway IP address: GATEWAY="192.168.10.1"
That’s the permanent IP address configuration in Slackware Linux. Everytime you reboot the system, the configuration will be run at boot time.
In Redhat Linux family such as RedHat Enterprise Linux (RHEL), CentOS, and Fedora you can use the ‘system-config-network’ script and follow the onscreen steps. The script will write the configuration files located in ‘/etc/sysconfig/network-scripts/’ directory. The IP address configuration file for the eth0 interface is ‘ifcfg-eth0’. The file should contain similar like below:
# Intel Corporation 80003ES2LAN Gigabit Ethernet Controller (Copper) DEVICE=eth0 BOOTPROTO=none BROADCAST=192.168.10.255 HWADDR=00:15:17:17:6A:84 IPADDR=192.168.10.10 NETMASK=255.255.255.0 NETWORK=192.168.10.0 ONBOOT=yes GATEWAY=192.168.10.1 TYPE=Ethernet
You need to restart the current network service by issuing