Change from DHCP to Static ip Fedora/Centos
Static IP addresses are manually assigned to a computer by an administrator. The exact procedure varies according to platform. This contrasts with dynamic IP addresses, which are assigned either by the computer interface or host software itself, as in Zeroconf, or assigned by a server using Dynamic Host Configuration Protocol (DHCP).
Even though IP addresses assigned using DHCP may stay the same for long periods of time, they can generally change. In some cases, a network administrator may implement dynamically assigned static IP addresses. In this case, a DHCP server is used, but it is specifically configured to always assign the same IP address to a particular computer. This allows static IP addresses to be configured centrally, without having to specifically configure each computer on the network in a manual procedure.
In the absence of both an administrator (to assign a static IP address) and a DHCP server, the operating system may assign itself an IP address using state-less autoconfiguration methods, such as Zeroconf.
1. login as root
2. get your current IP address with this command:
The OUTPUT will look someting like this:
Unixmen-net:~ # ifconfig
eth0 Link encap:Ethernet HWaddr 00:0D:9D:57:44:90
inet addr:10.33.17.143 Bcast:10.33.17.255 Mask:255.255.255.0
inet6 addr: fe80::20d:9dff:fe57:4490/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:255590 errors:0 dropped:0 overruns:0 frame:0
TX packets:98902 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:124649019 (118.8 Mb) TX bytes:14457923 (13.7 Mb)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:18 errors:0 dropped:0 overruns:0 frame:0
TX packets:18 errors:0 dropped:0 overruns:0 carrier:0
RX bytes:1060 (1.0 Kb) TX bytes:1060 (1.0 Kb)
OR you can also get the ip from the network configuration file with this command:
COMMAND to show configuration:
THe OUTPUT will look like this (i have it set to DHCP)
3. Ok, on step 3 we are going to change from DHCP to static ip. so send this command to edit the /etc/sysconfig/network-scripts/ifcfg-eth0 file:
(you can other editor if you want like gedit pico nano..emacs)
Change from this:
# File: ifcfg-eth0
4. now save your changes and reboot your server.