LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Blogs > farslayer
User Name
Password

Notices


Rate this Entry

Setting the Linux Hostname

Posted 03-02-2009 at 08:49 AM by farslayer
Updated 05-27-2009 at 03:12 PM by farslayer
Tags hostname

Originally Copied from http://www.cpqlinux.com/hostname.html
The original site has been down the last several times I have checked, so I am reposting the info here in my blog..




Setting the Linux Host Name


Start at the top and complete ALL steps..

-------------------------------------------------------------------------------
Checking your Linux host name
First, see if your host name is set correclty using the following commands:

Code:
uname -n
hostname -a
hostname -s
hostname -d
hostname -f
hostname
If the above commands return correctly with no errors then all may be well; however, you may want to read on to verify that all settings are correct.

-------------------------------------------------------------------------------
Configuring /etc/hosts
If your IP address is assigned to you by a DHCP server, then /etc/hosts is configured as follows:
Code:
127.0.0.1	mybox.mydomain.com	localhost.localdomain localhost mybox
If you have a static IP address, then /etc/hosts is configured as follows:

Code:
127.0.0.1	localhost.localdomain localhost
192.168.0.10	mybox.mydomain.com	mybox
--------------------------------------------------------------------------------
Setting the Host Name using "hostname"
After updating the /etc/hosts file correctly, the "hostname" command should be run as follows to set your hostname:

Code:
hostname mybox.mydomain.com
---------------------------------------------------------------------------------
Checking /etc/HOSTNAME (if present)

You may or may not have the file /etc/HOSTNAME:
Code:
mybox.mydomain.com
--------------------------------------------------------------------------------
Checking /etc/sysconfig/network

If you have a static IP address, then /etc/sysconfig/network is configured as follows:

Code:
NETWORKING=yes
HOSTNAME="mybox.mydomain.com"
...


If your IP address is assigned to you by a DHCP server, and you wish to update the local DNS server through Dynamic DNS, then /etc/sysconfig/network is configured as follows:

Code:
NETWORKING=yes
HOSTNAME="mybox.mydomain.com"
DHCP_HOSTNAME="mybox.mydomain.com"
...
-------------------------------------------------------------------------------

Checking /proc/sys/kernel/hostname



This is checked with the following command:

Code:
cat /proc/sys/kernel/hostname


If you need to set this file, you can either reboot or set it now with the following command:
Code:
echo mybox.mydomain.com > /proc/sys/kernel/hostname

-------------------------------------------------------------------------------
Dynamic DNS - Updating the local DNS server with your host name and DHCP IP

If you receive your IP address from a DHCP server, you may update the local DNS server by adding the following line to /etc/sysconfig/network for Red Hat:

Code:
DHCP_HOSTNAME="mybox.mydomain.com"

or if running Debian, edit /etc/network/interfaces as follows (adding the hostname line):
Code:
iface eth0 inet dhcp
    hostname mybox.mydomain.com

For more info in Debian, see "man interfaces" and scroll down to "The dhcp Method".

---------------------------------------------------------------------------------
WINS - Updating the local WINS server with your host name and IP

If you wish to update the local WINS server, then use SAMBA, and configure it to point to the local WINS server.
Views 15187 Comments 2
« Prev     Main     Next »
Total Comments 2

Comments

  1. Old Comment
    Thanks
    Posted 05-08-2009 at 01:00 AM by vasco.debian vasco.debian is offline
  2. Old Comment
    This is very useful information. Had trouble changing hostnames. This should make things clear. Thanks a lot.

    P.S.: I think openSUSE has /etc/HOSTNAME. Didnot find it in others I have tried.
    Posted 05-12-2009 at 08:38 AM by saivin saivin is offline
 

  



All times are GMT -5. The time now is 04:14 PM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration