Advertisement
Home arrow Linux Shell commands arrow Changing hostname and IP on a CentOS server
Changing hostname and IP on a CentOS server
Written by wiredgorilla   
Friday, 12 September 2008

OK, so you are ready to move your server to a different datacenter with a different IP C class.

Here are a few things you need to change

1/ RedHat based system use the file /etc/sysconfig/network to read the saved hostname at system boot. This is set using the init script /etc/rc.d/rc.sysinit

nano /etc/sysconfig/network

NETWORKING=yes
HOSTNAME="plain.domainname.com"
GATEWAY="111.222.333.1"
GATEWAYDEV="eth0"
FORWARD_IPV4="yes"

 

 

2/ TCP/IP Network Configuration Files

This configures Linux so that it knows which DNS server will be resolving domain names into IP addresses

  nano /etc/resolv.conf

 

search name-of-domain.com - Name of your domain or ISP's domain if using their name server
nameserver XXX.XXX.XXX.XXX - IP address of primary name server
nameserver XXX.XXX.XXX.XXX - IP address of secondary name server

 3/ Locally resolve node names to IP addresses

nano /etc/hosts

 

::1             localhost6.localdomain6 localhost6
# Do not remove the following line, or various programs
# that require network functionality will fail.
111.222.333.444            yourname.server.com yourname
127.0.0.1               localhost

 

4/ Configuration settings for your first ethernet port

nano /etc/sysconfig/network-scripts/ifcfg-eth0

 

DEVICE=eth0
BOOTPROTO=static
BROADCAST=111.222.333.255
IPADDR=111.222.333.444
NETMASK=255.255.255.0
NETWORK=111.222.333.0
ONBOOT=yes
 

And to finalize , you need to restart your network

 

service network restart

 

Hopefully those steps will help you to get you on the road :)

 


 

 





Reddit!Del.icio.us!Google!Live!Facebook!Slashdot!Netscape!Technorati!StumbleUpon!Newsvine!Furl!Yahoo!Ma.gnolia!Free social bookmarking plugins and extensions for Joomla! websites!
Last Updated ( Friday, 30 January 2009 )
 
Next >