kurajesh
asked on
hostname change in linux server
i had a hostname for one of my linux server (oel 5.5) and there was a need to change that , hence i changed in /etc/sysconfig/network and also in vi /etc/hosts. rebooted tthe server but still when i open a terminal it shows the old name and hostname also returns the old name.
how to update the hostname correctly
how to update the hostname correctly
hostname newname
Looks like you have already done these steps
Open file /etc/sysconfig/network using editor Change entry HOSTNAME=XXXXXX to HOSTNAME=New_Host_Name
You may also want to check this entry in /etc/sysconfig/network-scr ipts/ifcfg -xxx file. Some times hostname is set in this file.
Open file /etc/sysconfig/network using editor Change entry HOSTNAME=XXXXXX to HOSTNAME=New_Host_Name
You may also want to check this entry in /etc/sysconfig/network-scr
ASKER
Ues farzan I have done the first two already. Need to check you suggestion which I will do it and update soon
ASKER
Actually I have done like the following
I have two linux servers namely prod and test
We had to rename test as prod and prod to vision
Renaming of prod to vision happenned successfully whereas test to prod is the issue. I edited in etc/hosts of test and made changes name as prod and rebooted the server. Checked the hostname and returned as test. This is the issue
I just thought explain the real scenario.
I have two linux servers namely prod and test
We had to rename test as prod and prod to vision
Renaming of prod to vision happenned successfully whereas test to prod is the issue. I edited in etc/hosts of test and made changes name as prod and rebooted the server. Checked the hostname and returned as test. This is the issue
I just thought explain the real scenario.
have you tried entering the command on prod after making the changes on /etc/sysconfig/network and /etc/hosts
hostname prod
This sets the hostname on the linux box without rebooting.
If you need them to be persistent across reboots you had them to /etc/sysconfig/network as other experts have pointed.
If you need it to resolve from your linux box you had to /etc/hosts.
Hope it helps,
-Lego
hostname prod
This sets the hostname on the linux box without rebooting.
If you need them to be persistent across reboots you had them to /etc/sysconfig/network as other experts have pointed.
If you need it to resolve from your linux box you had to /etc/hosts.
Hope it helps,
-Lego
[Corrected]
If you need it to resolve from your linux box you have to edit /etc/hosts* (My bad)
If you need it to resolve from your linux box you have to edit /etc/hosts* (My bad)
3 of the already posted steps really should work:
1: change /etc/hosts to: 127.0.0.1 localhost
127.0.0.1 prod prod.domain.com
123.45.67.89 prod prod.domain.com
2: change /etc/sysconfig/network to: HOSTNAME=prod
3: run the command: hostname prod
4: reboot, just to be 100% sure it sticks.
I have another somewhat convoluted solution that seems to always work when we have this problem. Let me know if it's still not working, and I'll post it next.
1: change /etc/hosts to: 127.0.0.1 localhost
127.0.0.1 prod prod.domain.com
123.45.67.89 prod prod.domain.com
2: change /etc/sysconfig/network to: HOSTNAME=prod
3: run the command: hostname prod
4: reboot, just to be 100% sure it sticks.
I have another somewhat convoluted solution that seems to always work when we have this problem. Let me know if it's still not working, and I'll post it next.
Be sure you are not using invalid characters in your host name. So letters, numbers and dashes only.. no underscores, etc.
ASKER
i have done all the above inlcuding digus suggestion, but still it returns the same result.
any other idea
any other idea
When I absolutely can't get anything else at all to work, I use webmin: http://www.webmin.com
After it is installed, login and go to:
the networking tab,
then "Network Configuration"
then "Hostname and DNS Client"
then change the "hostname" box (if it already says prod, just hit save)
then click "Module Index"
then click the "Apply Configuration" button.
It's a hassle, but it has always worked for me when nothing else has. It is also a very nice and simplified GUI for *nix boxes. I just hate to see people use it as a "crutch".
Good Luck!
After it is installed, login and go to:
the networking tab,
then "Network Configuration"
then "Hostname and DNS Client"
then change the "hostname" box (if it already says prod, just hit save)
then click "Module Index"
then click the "Apply Configuration" button.
It's a hassle, but it has always worked for me when nothing else has. It is also a very nice and simplified GUI for *nix boxes. I just hate to see people use it as a "crutch".
Good Luck!
Do you have a Domain Name Server?
If so, did you update the DNS tables with the new values?
Do you use DHCP with hostname management?
If so, has the DHCP server's setup been changed accordingly?
Do you use NIS to distribute "hosts.byname" or "hosts.byaddr"?
Check with "ypwhich -m"
If so, does the hosts map contain the new values?
Is your "hostname" command indeed "/usr/bin/hostname"?
Check with "which hostname" or "whence -v hostname" and "alias hostname".
If it's something else try to find out what it does.
wmp
If so, did you update the DNS tables with the new values?
Do you use DHCP with hostname management?
If so, has the DHCP server's setup been changed accordingly?
Do you use NIS to distribute "hosts.byname" or "hosts.byaddr"?
Check with "ypwhich -m"
If so, does the hosts map contain the new values?
Is your "hostname" command indeed "/usr/bin/hostname"?
Check with "which hostname" or "whence -v hostname" and "alias hostname".
If it's something else try to find out what it does.
wmp
ASKER
we have a dns server and its ip address has been mentioned in dns config of linux server.
also linux server is having a static ip address.
"ypwhich -m"
ypwhich: can't get local yp domain: Local domain name not set
which hostname
/bin/hostname
still the issue persists
also linux server is having a static ip address.
"ypwhich -m"
ypwhich: can't get local yp domain: Local domain name not set
which hostname
/bin/hostname
still the issue persists
You need to set your NIS domain name to "example.com"
Enter the command,
domainname example.com
vi /etc/sysconfig/network
(and enter or edit this line)
NISDOMAIN example.com (I don't remember if there is an equal to between NISDOMAIN and example.com but you can check)
Enter the command,
domainname example.com
vi /etc/sysconfig/network
(and enter or edit this line)
NISDOMAIN example.com (I don't remember if there is an equal to between NISDOMAIN and example.com but you can check)
You did not try webmin then.
ASKER
I did try webamin and it is installed already. I accessed from my desktop and there in hostname and dns config it shows the right hostname. Absolutely no issues but when I enter hostname in terminal it returns as test itself.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You might try
# grep -iR "old_hostname" /etc/*
and see if the hostname is being set somewhere else as well.
# grep -iR "old_hostname" /etc/*
and see if the hostname is being set somewhere else as well.
@11bytes - good call!
ASKER
hi all,
as digus was saying "Seems like we may be overlooking something really simple here" , right there is an entry in one of the file
sysctl.conf and there was an entry called kernel.hostname and is was test and chanegd to prod and worked .
thanks a lot guys for your wonderful support.
as digus was saying "Seems like we may be overlooking something really simple here" , right there is an entry in one of the file
sysctl.conf and there was an entry called kernel.hostname and is was test and chanegd to prod and worked .
thanks a lot guys for your wonderful support.
126.20.80.60 test.human.com test
2) /etc/sysconfig/network
active your etho (ethernet adpator)
3) type command service network restart .
5) check hostname