This howto is intended to provide the information needed to set up Static IP Addressing. I use Mandriva 2007 and am not sure how closely other distro's follow the same file naming scheme.
Setting up Static IP Addressing involves checking and/or editing 4 files. You may want to make copies of your current files just so you have them to fall back on if something goes wrong. The files are:
/etc/resolv.conf
/etc/hosts
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
Your ifcfg file may differ, eth0, eth1, wlan0, etc.
The numbers used below are purely examples only. Replace values appropriately for your network.
This example includes wireless, if you don't have wireless leave out those fields. These are the fields required for the /etc/sysconfig/network-scripts/ifcfg-eth0 file:
DEVICE=eth1 BOOTPROTO=static IPADDR=192.168.0.2 NETMASK=255.255.255.0 NETWORK=192.168.0.0 BROADCAST=192.168.0.255 ONBOOT=yes MII_NOT_SUPPORTED=yes WIRELESS_MODE=Managed WIRELESS_ESSID=any WIRELESS_ENC_KEY=""
The numbers used below are purely examples only. Replace values appropriately for your network.
Next is the /etc/sysconfig/network file:
HOSTNAME=something-cool NETWORKING=yes GATEWAY=192.168.0.1 GATEWAYDEV=eth1
The numbers used below are purely examples only. Replace values appropriately for your network.
The /etc/hosts file needs the IP and Hostname added to it:
127.0.0.1 localhost 192.168.0.2 something-cool
The numbers used below are purely examples only. Replace values appropriately for your network.
Last is the /etc/resolv.conf file which contains the DNS IP's:
nameserver 205.221.122.145 nameserver 205.221.122.142
Once the 4 files have been checked and edited, simply restart the network as root:
service network restart
Once the network is restarted you can type the following command as normal user or root user to verify your static IP is now set appropriately:
/sbin/ifconfig
