Difference between revisions of "Linux/Network/Change ip"

From Iveze
< Linux‎ | Network
Jump to: navigation, search
(Created page with "If a server is moved to another network the static ip often needs to be modified. This must be done before connecting the network, with hardware monitor and keyboard. First ch...")
 
Line 1: Line 1:
If a server is moved to another network the static ip often needs to be modified. This must be done before connecting the network, with hardware monitor and keyboard. First check which ip can be used as static. Find out which ip range is used by dhcp and choose an unused address outside the dhcp range. Then edit the ifcfg file, which is often called ifcfg-eth0, but sometimes it has a different name. Then it is the one that is not called ifcfg-lo.  
+
If a server is moved to another network the static ip often needs to be modified. This must be done before connecting the network cable, with hardware monitor and keyboard. First check which ip can be used as static. Find out which ip range is used by dhcp and choose an unused address outside the dhcp range. Then edit the ifcfg file, which is often called ifcfg-eth0, but sometimes it has a different name. Then it is the one that is not called ifcfg-lo.  
 
  vi /etc/sysconfig/network-scripts/ifcfg-eth0
 
  vi /etc/sysconfig/network-scripts/ifcfg-eth0
 
In that file you will find several lines containing ip adresses. They must be changed to fit the new network.<blockquote>IPADDR="The ip outside the dhcp range"<br>
 
In that file you will find several lines containing ip adresses. They must be changed to fit the new network.<blockquote>IPADDR="The ip outside the dhcp range"<br>

Revision as of 13:16, 4 June 2015

If a server is moved to another network the static ip often needs to be modified. This must be done before connecting the network cable, with hardware monitor and keyboard. First check which ip can be used as static. Find out which ip range is used by dhcp and choose an unused address outside the dhcp range. Then edit the ifcfg file, which is often called ifcfg-eth0, but sometimes it has a different name. Then it is the one that is not called ifcfg-lo.

vi /etc/sysconfig/network-scripts/ifcfg-eth0
In that file you will find several lines containing ip adresses. They must be changed to fit the new network.
IPADDR="The ip outside the dhcp range"

NETWORK="The ipaddr with a 0 on the fourth position"
GATEWAY="The ip of the router to the internet"
DNS1="The ip of the first dns server"
DNS2="The ip of the second dns server"

SEARCH="The workgroup name of smb servers in your network"
After saving these changes the network needs to be restarted.

Centos 6:

/etc/init.d/network restart

Centos 7:

systemctl restart network

Now the network can be connected and ssh used to operate the server.