Wednesday, June 28, 2006

Linux: Setting the Hostname

This is useful when your linux box is used for sending emails. If hostname is incorrect, it will be detected by http://cbl.abuseat.org and will be blocked from sending emails.

Example of a computer's hostname: mybox.mydomain.com

Replace example hostname to your computer's hostname.

In Linux, to check the hostname if it is similar to this example:

[root@mybox ~]# uname -n
mybox.mydomain.com
[root@mybox ~]# hostname -s
mybox
[root@mybox ~]# hostname -d
mydomain.com
[root@mybox ~]# hostname -f
mybox.mydomain.com
[root@mybox ~]# hostname
mybox.mydomain.com

If it returns localhost.localdomain then it's wrong. If not then your linux box is ok. (Very big hint for me was that before, the command prompt was [root@localhost ~]#)

For a static IP Address, /etc/hosts is configured as follows:
127.0.0.1 localhost.localdomain localhost
192.168.0.xxx mybox.mydomain.com mybox


Change 192.168.0.xxx to your static IP Address.

Set hostname:
[root@localhost ~]# hostname mybox.mydomain.com

Check /etc/sysconfig/network file. Must have be like this:
NETWORKING=yes
HOSTNAME="mybox.mydomain.com"

For further reference:
http://www.cpqlinux.com/hostname.html

* Using Fedora Core 3

No comments: