LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Fully qualified hostname (https://www.linuxquestions.org/questions/linux-newbie-8/fully-qualified-hostname-208663/)

gubak 07-23-2004 06:43 AM

Fully qualified hostname
 
How can I ask for a fully qualified hostname or for a hostname?

Donboy 07-23-2004 07:28 AM

How can you ASK for one??? Well, the hostname is just the name of your computer. Just type "hostname" at the command prompt and you can see the computer's name. If you want to change it, try "man hostname" to see what options you can give the hostname command.

Some tutorials will ask for a fully qualified domain name (FQDN) which is the hostname plus a domain name. So "hostname.yourdomain.com" is a FQDN.

calluminsky 07-23-2004 07:43 AM

Gubak

You may also need to put an entry in your /etc/hosts file too for your hostname. The format will resemble:

127.0.0.1 localhost.domainname.com
192.160.100.1 yourmachine.yourdomain.com yourmachine

The third entry on the second line is just an alias for ease of use.

Hope that helps.

Calluminsky

0perat0r 07-23-2004 08:07 AM

Editing etc/hosts does not work for me (I loose my connection to the Internet). I have not tried this yet, but a UNIX guru I work with told me to try altering /etc/sysconfig/network. Please proceed with caution, as always :)

Donboy 07-23-2004 10:29 AM

I'm not totally sure about this, but I believe /etc/sysconfig/network is only on RH and Fedora distros. I think other distros do it differently. But dont' quote me on that... I could be way off. And yes, you REALLY want to be careful in there because this is what your ethernet card uses when you restart the comptuer or restart your network. I DEFINITELY recommend saving a backup copy of this if you try to fiddle with it. Also google yourself silly on the contents of those files because the system is pretty picky about what goes in there and in what syntax. Basically this is like the permenent info stored on the computer that represents what you see when you run the ifconfig command.

You should be able to edit /etc/hosts without the internet being connected.

But then... aren't we getting way off topic here? I don't even know if we are helping the original poster with his question or not.

0perat0r 07-23-2004 12:40 PM

The question was somewhat vague to begin with (no offense intended to the orginal poster). Irregardless, you can find the same information in both /etc/hosts and /etc/sysconfig/network. I'm not sure how they differ or what the consequences of changing /etc/sysconfig/network are.

Donboy 07-23-2004 02:00 PM

Well, as long as we're off topic anyway... what the hell!

/etc/hosts is where you define mappings between IP addresses and hostnames. So if you have another machine on your local network you can put the IP followed by the hostname so that the computer you're using knows what IP address needs to be queried whenever that hostname is used. It's like a mini DNS system.

On RH and Fedora, the file is /etc/sysconfig/network-scripts/ifcfg-eth0 where eth0 is the ethernet card's ID. This is just a regular file you can edit that has name/value pairs. You can edit these to change the properties of your ethernet card (in this case, eth0) and it will apply them when you do "service network restart" or reboot the machine. As I said before... be careful, make backups of this file, and try to be sure you know what you're doing when you change that stuff.

Lleb_KCir 07-23-2004 07:18 PM

Quote:

Originally posted by 0perat0r
Editing etc/hosts does not work for me (I loose my connection to the Internet). I have not tried this yet, but a UNIX guru I work with told me to try altering /etc/sysconfig/network. Please proceed with caution, as always :)
editing that file on RH9 works just fine. you need to be root, and you need to stay root to 'service network restart' as well.

FYI, thanks for the reminder, this was something i had forgotten about doing the last time i rebuilt my RH system.

Lleb_KCir 07-23-2004 11:56 PM

extra note:

when you edit your /etc/sysconfig/network file you will also need to add a line to your /etc/host file to match the new name you just gave your system. example:

this is the /etc/sysconfig/network

Code:

NETWORKING=yes
HOSTNAME=systemname.donaim

this is the /etc/hosts

Code:

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1                localhost.localdomain localhost
127.0.0.1                  systemname.donaim


you want to keep the first line in the /etc/hosts alone, then just add the next line 127.0.0.1 ... and you should be set.

best of luck.

FYI, if you forget to add the line to the /etc/hosts file you will get an error when trying to log into gnome, and i can only guess into kde too, telling you it can not resolve the systemname.donaim and to add it to your /etc/hosts file and you will be set. just click the login anyways button to get past that error msg.


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