Friday, June 5, 2009

CentOS, change hostname and IPs

first, become root:

sudo su -
(enter your pw)

To change IP:

ifconfig add eth0 192.168.63.129

see http://dhika.cikul.or.id/how-to-change-centos-ip-address.html

quote:
ifconfig command create temporary IP address change, if you reboot your server, you will see that your IP still not change. If you want make permanent ip change, you must edit files under /etc/sysconfig/network-scripts/
unquote.


and edit your /etc/hosts file

cd /etc/sysconfig/network-scripts/
vi ifcfg-eth0

DEVICE=eth0
BOOTPROTO=static
IPADDR=172.17.17.10
NETMASK=255.255.255.248
ONBOOT=yes

cp ifcfg-eth0:0
and edit correspondingly
service network restart

MAKE SURE your NETMASK is the same as the host machine, otherwise the 2 won't be able to communicate....

here the instructions are more precise:

http://www.xenocafe.com/tutorials/linux/redhat/bind_multiple_ip_addresses_to_single_nic/index.php


To change hostname:


then echo “newhostname” > /proc/sys/kernel/hostname

or

sysctl kernel.hostname=NEW_HOSTNAME

and edit /etc/sysconfig/network to set HOSTNAME to the value you need

see here http://www.ducea.com/2006/08/07/how-to-change-the-hostname-of-a-linux-system/

also, run system-config-network and change hostname under DNS tab,
logout then login again

finally, add the new hostname to the hosts file

No comments: