This is a newbie question I get quite often.

Configuring your Linux machine to run on a static IP is easy. Tools like system-config-network and netconfig provide you simple GUIs to do this.

For today, I’ll show you how to do this from the command line instead.

Navigate to /etc/sysconfig/network-scripts/
<br /> [[email protected]]# cd /etc/sysconfig/network-scripts/

Every network interface will have it’s own interface script file. eth0,eth1,eth2 and so on. Vi the ifcfg-eth0 interface script file for interface eth0. Replace the contents of the ifcfg-eth0 file with the parameters below.

[[email protected]]# vi ifcfg-eth0.
<br /> DEVICE=eth0<br /> TYPE=Ethernet<br /> ONBOOT=yes<br /> BOOTPROTO=none<br /> IPADDR=<br /> NETMASK=<br /> GATEWAY=<br /> HWADDR=00:0F:22:71:0A:53<br /> USERCTL=no<br /> USERCTL=no

If you want to switch back to DHCP, repeat the steps above and replace the contents of the ifcfg-eth0 file with the parameters below.

DEVICE=eth0<br /> BOOTPROTO=dhcp<br /> HWADDR=00:0F:20:71:0A:50<br /> ONBOOT=yes<br /> TYPE=Ethernet<br />

Restart your interface to apply the changes.
<br /> [[email protected]]#ifdown eth0<br /> [[email protected]]#ifup eth0

To update your dns server settings, modify the /etc/resolv.conf.

[[email protected]]# vi /etc/resolv.conf

Replace the contents of the resolv.conf file with the parameters below. The first parameter “search” is your search path followed the nameserver parameters which hold the IPs for your primary and secondary DNS servers.
<br /> search<br /> nameserver<br /> nameserver

That’s it. Drop me a note if you need any help.