Linux - Setting Static IP Address

Just a simple reference on how to set static IP address on Linux via command line

I using CentOS 5.6 x64 with only 1 network interface.

1. Use an editor (such as vi) to edit /etc/sysconfig/network-scripts/ifcfg-eth0
2. At ifcfg-eth0, do the following in bold. Note: IP address and net mask is only an example.

Change BOOTPROTO=dhcp ----> BOOTPROTO=static

Add IPADDR=192.168.1.250

Add NETMASK=255.255.255.0

3. Save ifcfg-eth0
4. Use an editor (such as vi) to edit /etc/sysconfig/network
5. At network, do the following in bold. Note: Gateway is only an example

Add GATEWAY=192.168.1.1

6. Save network
7. Restart the network interface by service network restart
8. Alternatively, you can restart your server to check if the changes is persistence with reboot

See http://www.cyberciti.biz/faq/linux-configure-a-static-ip-address-tutorial/

Comments

Popular Posts