PDA

توجه ! این یک نسخه آرشیو شده میباشد و در این حالت شما عکسی را مشاهده نمیکنید برای مشاهده کامل متن و عکسها بر روی لینک مقابل کلیک کنید : چگونگی عوض کردن ای پی سرور در لینوکس



Vahid
August 6th, 2008, 02:41
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.