LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Changing HOSTNAME in mandriva 2009 (https://www.linuxquestions.org/questions/linux-newbie-8/changing-hostname-in-mandriva-2009-a-708574/)

ServalSoft 03-02-2009 07:47 AM

Changing HOSTNAME in mandriva 2009
 
I have tried changing my hostname which currently is "localhost" to "myBOX" without success; I have tried editing some of the files advised on this site and others without success, any help will be appreciated.
The changes I made so far were
vi /etc/sysconfig/network
#I added the line HOSTNAME = myBox
Rebooted the machine, no change, i did the same thing as advised on another site with the files
/etc/sysconfig/network-scripts/ifcfg-eth0
and
/etc/sysconfig/network-scripts/ifcfg-wlan0

still no change after rebooting, I still have "[myname@localhost]$ " on my command prompt :(

farslayer 03-02-2009 08:11 AM

Try following this guide..

http://linux-journal.blogspot.com/20...host-name.html

Should get you sorted just fine,.

ServalSoft 03-02-2009 08:58 AM

Thanks, I followed the direction in the guide, but I am still a bit confused; I rebooted the machine and it still shows my hostname as "localhost" on the terminal, and when I type "$hostane" or "$uname -n" on the terminal I get printed "localhost", however I get the desired result with "$hostname -f" and "$hostname -s".
Any idea on why this is happening???

jkzfixme 03-02-2009 10:16 AM

enter this as root

Quote:

vi /etc/hosts
Quote:

127.0.0.1 localhost.localdomain localhost
192.168.0.100 mybox.com mybox
wheras 192.168.0.100 is your ip

now you check it

Quote:

hostname
hostname -f
If that didn't work you can do this

Quote:

echo mybox.com > /etc/hostname
/bin/hostname -F /etc/hostname
Regards,
JKZfixme

ServalSoft 03-02-2009 10:55 AM

I tried the above, with no succses; this is what /etc/hosts looks like:
# generated by drakhosts
#127.0.0.1 drivaBOX.YANHOME localhost.localdomain localhost
192.168.1.8 YANHOME drivaBOX

ps: I also tried with the 2nd line uncommented, same result.

and this is a copy of /etc/sysconfig/network
NETWORKING=yes
HOSTNAME = "drivaBOX.YANHOME"
DHCP_HOSTNAME = "drivaBOX.YANHOME"

I also would like to add that here the hostname is drivaBOX and the localdomain is YANHOME.

farslayer 03-02-2009 03:02 PM

If you did all 6 steps in that document I posted I would be really surprised if it did not work.

Are you sure you didn't skip any steps at all ?

Following that entire guide, you would not need to reboot for the new hostname to be active.
the /proc/sys/kernel/hostname step will make the final change on the fly.

ServalSoft 03-02-2009 04:35 PM

As far as I can see I did not miss a single step, below is a copy of the edited files you mention in the tutorial, I hope you can make sense of it. There is something however I am not to sure about is what you mean by receiving the IP from a DHCP server, on my wlan comfiguration it is mean to be getting the ip automatically. it is not a manual configuration.

Code:

[root@localhost yanick]# uname -n
localhost
[root@localhost yanick]# hostname -a
localhost.localdomain localhost
[root@localhost yanick]# hostname -d
YANHOME
[root@localhost yanick]# hostname -f
drivaBOX.YANHOME
[root@localhost yanick]# hostname
localhost
[root@localhost yanick]#

/etc/hosts
127.0.0.1 drivaBOX.YANHOME  localhost.localdomain localhost
192.168.1.8 YANHOME drivaBOX

/etc/sysconfig/network
NETWORKING=yes
HOSTNAME = "drivaBOX.YANHOME"
DHCP_HOSTNAME = "drivaBOX.YANHOME"

I didnt think it would be so much headache just to change the box name from one to the other.

ServalSoft 03-02-2009 06:32 PM

Quote:

Originally Posted by farslayer (Post 3462782)
If you did all 6 steps in that document I posted I would be really surprised if it did not work....

Hey, it seems that you were right, I tried to steps again, and this time it worked, I am right in the middle of something so I can't restart the pc now to check if my settings survived a reboot. "I hope they did". in any case, thanks you very much for your help.

farslayer 03-02-2009 08:40 PM

It should survive a reboot without any trouble.

Glad you got it all sorted out.

ServalSoft 03-03-2009 08:50 PM

Unfortunately, the settings do not survive a reboot, the only way I get it to work, is by following the steps, then after I have to log out and log back in to get the desired result. What I realise was after a reboot, i have to go into the terminal and issue the command
Code:

#hostname drivaBOX.YANHOME
, then log out and back in. When I reboot, everything is gone. Just another area where I think it might be the problem, when you say if the IP is auto assigned by DHCP you mean an auto configuration right? because when I connect to my WLAN, I let the system assigned the IP address. this is a copy of some of my set files:
The first fragment is where I am a lil bit confused as to what to enter. I am connected to the internet through a wireless router, and every computers in the house have their IP automatically assigned.
Code:

/etc/hosts
$ cat /etc/hosts
# generated by drakhosts
127.0.0.1 drivaBOX.YANHOME  localhost.localdomain localhost drivaBOX
192.168.1.8 YANHOME drivaBOX

and

Code:


$ cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME = "drivaBOX.YANHOME"
DHCP_HOSTNAME = "drivaBOX.YANHOME"

Thanks for your time

farslayer 03-03-2009 11:10 PM

When you say everything is gone do you mean all the files you changed reverted back to their previous settings ? That certainly shouldn't happen, unless dhcp is overwriting the changes..

Mandriva Docs..
http://wiki.mandriva.com/en/Docs/Sys...m.27s_Hostname
Quote:

Assuming that the interface to your LAN and/or broadband modem and/or router is eth0, next edit the /etc/sysconfig/network-scripts/ifcfg-eth0 file, editing/adding this line:

Code:

NEEDHOSTNAME=no
If you are experiencing issues with retaining your hostname and you utilize DHCP add the following line to /etc/sysconfig/network-scripts/ifcfg-eth0
Code:

DHCP_HOSTNAME=yourhostname.localdomain


ServalSoft 03-04-2009 03:21 AM

No I dont meant the files are being reverted to the original, I mean the hostname gets changed back to localhost. And I can only set it to drivaBOX by issuing the command "$hostname drivaBOX.YANHOME", then logging out and logging back in again. But if I restart the laptop, I am back to "localhost" at the prompt. I am connection to my router using wifi, I therefore edited the

/etc/sysconfig/network-scripts/ifcfg-wlan0 as follow:
Code:


DEVICE=wlan0
BOOTPROTO=dhcp
ONBOOT=yes
METRIC=35
MII_NOT_SUPPORTED=no
USERCTL=yes
RESOLV_MODS=no
WIRELESS_MODE=Managed
WIRELESS_ESSID=YanWLan
WIRELESS_ENC_KEY=a1b2c3d4e5
WIRELESS_ENC_MODE=open
WIRELESS_WPA_DRIVER=wext
WIRELESS_WPA_REASSOCIATE=no
IPV6INIT=yes
IPV6TO4INIT=yes
DHCP_CLIENT=dhclient
NEEDHOSTNAME=no
PEERDNS=yes
PEERYP=yes
PEERNTPD=no
DHCP_HOSTNAME = drivaBOX.YANHOME

Note I added the last line. I also did the same for my ethernet card just in case.
/etc/sysconfig/newtwork-scripts/ifcfg-eth0
Code:

DEVICE=eth0
BOOTPROTO=dhcp
NETMASK=255.255.255.0
ONBOOT=yes
METRIC=10
DHCP_HOSTNAME=drivaBOX.YANHOME

I rebooted, and still the changes were not perpanent. any ideas?? or do I just need to resolve myself to using the default "localhost" as hostname?

farslayer 03-04-2009 08:35 AM

Either that or assign your box a static IP address..

I'm rather stumped, it appears you have applied all the workarounds recommended, and those from the Mandriva docs, yet it's not sticking..

Does your router have the ability to hand out hostnames as part of the DHCP offer ? if so you could make a reservation for your NIC, so you would always get the same IP and hostmname via dhcp..

ServalSoft 03-04-2009 09:19 AM

If you mean can I assign static IP to machines on my network, yes I can, I tried it before with my windows machine, and it works fine, I just choose to leave them to automatic because it is less settings for me to configure... Every time I used this machine to connect at home I get the assigned ip 192.168.1.8
I tried a debian and slack install once, and they both allowed me to choose the hostname during set up, maybe Mdriva should do the same...


All times are GMT -5. The time now is 09:00 AM.