Linux Tutorial: How to change the IP ADDRESS on a Linux machine

Article By : admin | User Rating : Average Rating : 6.00 From 15 Voter(s)

Linux Tutorial: How to change the IP ADDRESS on a Linux machine

Sometimes you run into situations where you need to change the IP address on a Linux server. If you are a "Windows" or "GUI" person, you might feel lost when you have to change the IP address of a Linux machine from the command line. But no worries, the actual process of changing the IP address is not that hard. Here is how it works:

Login to your server (preferrably via console or SSH) and switch to the root user

Now open the network configuration file. For this example we will use the default NIC (eth0).

#root: vi /etc/sysconfig/network-scripts/ifcfg-eth0

Your screen output will look like this

Now modify the configuration by using the "i" command to insert information. When you are done updating the file, hit "ESC" and save the settings with ":w" and exit out with ":x". The file has now been modified, but the changes have not been loaded yet. Next we want to change the host name and the default gateway of the machine. From the root prompt type the following:

#root: vi /etc/sysconfig/network

The screen output will look like this:


Now modify the configuration by using the "i" command to insert your new hostname and gateway information. When you are done updating the file, hit "ESC" and save the settings with ":w" and exit out with ":x". And again - the network configuration file has now been modified, but the changes have not been loaded yet.

The best way to have the changes take effect is to reboot the server if that is possible. If you are connecting remotely you want to make preparations to be able to connect again to the server. Make sure that the network switch supports the assigned IP address and gateway as otherwise your connection will fail. Send the server for a reboot with the following command:

#root: reboot

A second option is to restart the networking component, but sometimes a reboot is the better option when changing the IP address of a Linux server. On the command prompt type the following:

#root: service network restart

If all went well the server comes back with the new ip address and host name that you assigned.



Webhostingresourcekit.com - The home of free server tutorials, web hosting tutorials, cpanel tutorials, and hosting articles. 300+ articles and tutorials of web hosting help speak a clear language.






Related Articles

- cPanel or Plesk?
- Web Hosting from Your Web Server at Home


Send to a friend Send to a friend
Rate this Article :

1

2

3

4

5

6

7

8

9

10
Poor Excellent

SEARCH:
Advanced Search
CATEGORIES:
EXTERNAL RESOURCES:
FREE RESOURCES:
VISITOR GUIDES:
 
Copyright 2004 - 2008 | Webhostingresourcekit.com |