Monday, June 8, 2009

linux: setting your machine's hostname properly

To setup the hostname manually on a Fedora or RedHat box, you need to edit two files:
  • /etc/sysconfig/network
  • /etc/hosts
1.  In the /etc/sysconfig/network file, modify the hostname:
NETWORKING=yes
HOSTNAME=fedora.hacking.com
GATEWAY=10.7.0.1
  2.  In the /etc/hosts file, modify the hostname:
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 fedora.hacking.com fedora localhost.localdomain localhost

After making these changes to these files, the changes to the hostname should be permanent ( i.e. it will persist even across reboots). Otherwise, simply setting the hostname with the "hostname" command only affects the current session, and you lose the hostname change after the next machine reboot.

No comments: