Guest Daniel Posted March 28, 2003 Report Share Posted March 28, 2003 Can someone tell me how can I change my hostname on Mandrake I knew how be4, somehow I lost my touch I had try hostname <name> and reboot and it comes back as the one be4. I missing something here. thank you Daniel Quote Link to comment Share on other sites More sharing options...
Cannonfodder Posted March 28, 2003 Report Share Posted March 28, 2003 Do a search for hostname in the Search button above.. Quote Link to comment Share on other sites More sharing options...
aru Posted March 28, 2003 Report Share Posted March 28, 2003 Yes, it has already answered many times, but once more doesn't hurt :P Edit the file /etc/sysconfig/network, changing the HOSTNAME parameter (HOSTNAME=newhostname --w/o blank spaces--); and then run "service network restart") Quote Link to comment Share on other sites More sharing options...
Cannonfodder Posted March 28, 2003 Report Share Posted March 28, 2003 so the hostname terimnal command doesn't do a permanent change? Is this a bug? Quote Link to comment Share on other sites More sharing options...
aru Posted March 28, 2003 Report Share Posted March 28, 2003 so the hostname terimnal command doesn't do a permanent change? Is this a bug? No it is not a bug. The hostname command SETS the host name of the machine. That command is the (only?) way to set the host name of your machine, infact on boot the machine has no name, so /bin/hostname "somename" has to be run at some point to set the host name of the machine (in mandrake it is called from /etc/init.d/network); Is precisely in that moment where /etc/sysconfig/network plays a role since that file is sourced at the very begining of the script /etc/init.d/network So simplifying a bit: [*]/etc/sysconfig/network is just a bash-like configuration file in the form of VARIABLE_NAME=parameter [*]/etc/init.d/network is a bash script that sets up the network enviroment on boot, despite the machine is networked or not (the lo interface is always needed); among other things from that script is called /sbin/hostname $HOSTNAME where $HOSTNAME is just the value HOSTNAME=something which was previously sourced from /etc/sysconfig/network EDITED: I wrote this from memory, /sbin/hostname is not called from /etc/init.d/network, it is called even earlier on boot on /etc/rc.sysinit (*) [*]/sbin/hostname sets the name of the system (or just shows it if it is called w/o params This is how it works in redhat like systems (like mandrake); on other systems, such as slackware (BSD-ish), /sbin/hostname through intit scripts retrieves the name of the machine from /etc/HOSTNAME in a different approach HTH (*) so it makes no sense to run service network restart after changing /etc/sysconfig/network. What you have to do is after editing the /etc/sysconfig/network for future boots, run /sbin/hostname newname to apply the new name at the current session Quote Link to comment Share on other sites More sharing options...
Guest Daniel Posted March 28, 2003 Report Share Posted March 28, 2003 Thank you for replying I still don't get it, I checked the network file /etc/sysconfig and it was changed there, I rebooted the machine and there it goes, the orginal name come back when I open a terminal window. I checked the file again, "network" and it's my new hostname there without editing the file, it kept it. Somehow, somewhere, it doesn't read the file properly or there is another to edit. Maybe it is a bug? it's funny, this is on Mandrake 9.1, during the installation, it won't prompt you for a hostname. Thank you all have a nice day Quote Link to comment Share on other sites More sharing options...
phunni Posted April 3, 2003 Report Share Posted April 3, 2003 Bizarrely - I have the same problem, but only one of two machines that I have installed 9.1. on My main desktop works perfectly, but my server insists on calling itself dhcp-187-2742 An interesting factor is that my server has two NIC cards - one of which is getting it's ip dynamically - but my main desktop has a static ip - could this be the difference? Quote Link to comment Share on other sites More sharing options...
aru Posted April 3, 2003 Report Share Posted April 3, 2003 An interesting factor is that my server has two NIC cards - one of which is getting it's ip dynamically - but my main desktop has a static ip - could this be the difference? Probably you are right and it has to be something related to thw dhcp-server or something like that. I'm sorry to not be able to help here because I don't use that. My LAN machines have all static IPs and my internet connection is an isdn dialup, so everything works as it should be with /etc/sysconfig/network + /sbin/hostname + /etc/hosts Quote Link to comment Share on other sites More sharing options...
phunni Posted April 3, 2003 Report Share Posted April 3, 2003 Daniel - how do you get your ip? If you also get it dynamically frm your ISP then we may be on to something. This is still likely to be a mandrake problem though - I have used the same ISP for 8.0,8.2 & 9.0 - this is the first time I have not been able to change the hostname Quote Link to comment Share on other sites More sharing options...
Guest Daniel Posted April 3, 2003 Report Share Posted April 3, 2003 Got it it 's fixed thank you all, with the lovely forum board, i suceeded to change the hostname After ready upon the last two msg, I went to Control center network >I selected network and Internet connection >click on "wizard" >Select also "export mode" you will see that you have an option that says "dhcp select hostname" unselect that , remove the x mark and write you hostname above in the blank thank you Paul Quote Link to comment Share on other sites More sharing options...
sglafata Posted April 10, 2003 Report Share Posted April 10, 2003 I just added the line: hostname -F /etc/hostname to the end of my /etc/rc.local file. Of course, this also assumes that you have already created the hostname file in /etc. Just do a: touch /etc/hostname vi /etc/hostname Enter only the host name; nothing else. You can also run the first command for it to take effect right away. Quote Link to comment Share on other sites More sharing options...
aru Posted April 10, 2003 Report Share Posted April 10, 2003 but doing that at that late point you might annoy earlier launched services like cups, which need a proper hostname at their initialization (maybe I'm wrong an there is no problem at all in changing the hostname as late as in rc.local) Quote Link to comment Share on other sites More sharing options...
Cannonfodder Posted April 24, 2003 Report Share Posted April 24, 2003 I just followed Daniel's instructions on how to permanently change the hostname and it works like a charm. I also see what aru is talking about related to cups as the network script calls /bin/hostname. Have to wonder though whether /bin/hostname (a binary file) contains the actual hostname and is rebuilt each time I run the network setup in the mcc? Quote Link to comment Share on other sites More sharing options...
ranger Posted April 26, 2003 Report Share Posted April 26, 2003 it's funny, this is on Mandrake 9.1, during the installation, it won't prompt youfor a hostname. It does if you run the network setup in expert mode. Quote Link to comment Share on other sites More sharing options...
aru Posted April 26, 2003 Report Share Posted April 26, 2003 Have to wonder though whether /bin/hostname (a binary file) contains the actual hostname and is rebuilt each time I run the network setup in the mcc? It doesn't contain the hostname. I guess that mcc runs /bin/hostname "hostname", where "hostame" is what you have typed in the network form Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.