Hi all, Newbie question ..... I'm running Red Hat 7.1 at work on my laptop and the IP address is assigned via DHCP. If I want to change my hostname from "localhost.localdomain" to whatever I please, how do I do it? Be gentle ... Matthew
I'm running Red Hat 7.1 at work on my laptop and the IP address is assigned via DHCP. If I want to change my hostname from "localhost.localdomain" to whatever I please, how do I do it?
I don't know how much you know about networks, so forgive me if I'm telling you anything you already know. You'll always want to have references in your hostfile to "localhost" as this is pretty much the standard way of referencing the local machine, and not having a "localhost" reference in your /etc/hosts file will break some programs and scripts. Also, it helps to define what is ment by "localdomain". Whether or not your machine has a network interface device, like a modem, or ethernet card, there is always a built-in network device called the "loopback device" or "loopback interface". If you run ifconfig, you should see some data about that, in addition to any other network devices you may have. This loopback device isn't really a physical device, but rather a software construct that acts like a network device. It allows two network applications to communicate if they are running on the same machine. Your IP for this device is 127.0.0.1. This device also need a network address, And if memory serves, any packet sent to 127.x.x.x will be sent out the loopback interface (and also, recieved throught the loopback interface). 127.0.0.0 is the local domain. Here's what I have in my /etc/hosts file: -------- 127.0.0.1 tundra localhost tundra.abyss localhost.localdomain 192.168.42.2 savannah savannah.abyss --------- First, the background: This machine is on a home network with the domainname "abyss". There are 2 machines on this network: "tundra" and "savannah". The machine that I snagged this /etc/hosts file from is tundra. What the first line does is establish 4 names for this machine: localhost, tundra, tundra.abyss, and localhost.localdomain. The second line adds an entry for the other machine on the home network, savannah. There is also another file called /etc/networks, which defines the network names in the same way that /etc/hosts defined hosts names. Here's mine: ---------- localdomain 127.0.0.0 abyss 192.168.42.0 ---------- The first line established the network on loopback device (which only has one machine). the secons establishes the external network. As you can see, the local network (localdomain) is NOT the same as an external network. If you don't have your machine on a home lan, Finally, my machine now has 2 names tundra and localhost. my /etc/hostname file has to include my desired hostname. It contains only one line, which has the name I'd like to use for my machine. ----------- tundra ----------- Hope this helps.
On Thu, Jan 03, 2002 at 03:13:32PM -0500, Simoncini, Matthew wrote: simoncim> I'm running Red Hat 7.1 at work on my laptop and the IP address is assigned simoncim> via DHCP. If I want to change my hostname from "localhost.localdomain" to simoncim> whatever I please, how do I do it? This depends, do you want to fix it to a value of your own choosing (which may not match the DNS for the IP you get from DHCP), or do you want to have it set to whatever the DHCP server is giving you as a hostname (which will likely match the DNS for the IP it gave you)? For the former, you can set it in the file: /etc/sysconfig/network either add or edit the existing HOSTNAME= line: HOSTNAME=whateveryouwant.domain.com then reboot (which sets the hostname to the above value automatically) or set the hostname manually if you do not wish to reboot: hostname whateveryouwant.domain.com If you want DHCP to set your hostname, there are several options, depending on what DHCP client you are using (pump, dhcpcd, or dhclient). I always recommend dhclient over the other two. You can get it at http://www.isc.org/, or RPM packages for Red Hat 7.1 (recommended) at ftp://angus.ind.wpi.edu/pub/packages/isc/dhcp. Version 3.0 is the latest stable release, and 3.0.1rc4 is the latest release candidate. All you need is dhcp-3.0-1cra.i386.rpm and dhcp-client-3.0-1cra.i386.rpm. Install them like this (as root): rpm -Uvh dhcp-*3.0-1cra.i386.rpm The client package will automatically patch the necessary files in Red Hat (/sbin/ifup and /sbin/ifup if you are curious) to use dhclient before pump and/or dhcpcd if it exists. dhclient from the RPM packages will automatically set your hostname if the hostname is currently null, "(none)", "localhost" or "localhost.localdomain". You can control all sorts of behavior from the configuration file /etc/dhclient.conf. pump and dhcpcd I believe will also set the hostname if the current hostname matches the above list. They are supposed to do this one of two ways: 1. doing a reverse DNS lookup on the IP that DHCP assigns (pump --lookup-hostname or dhcpcd -H). or 2. using the hostname that DHCP passes back (pump -h or dhcpcd -h). You can force behavior 2 by setting the variable DHCP_HOSTNAME to anything in /etc/sysconfig/network: DHCP_HOSTNAME=yes Otherwise /sbin/ifup will use method 1. -- Charles R. Anderson <cra@wpi.edu> / http://angus.ind.wpi.edu/~cra/ PGP Key ID: 49BB5886 Fingerprint: EBA3 A106 7C93 FA07 8E15 3AC2 C367 A0F9 49BB 5886
participants (3)
-
Bryan Scaringe
-
Charles R . Anderson
-
Simoncini, Matthew