TIP Setup Your FQDN

From Gentoo Linux Wiki

Jump to: navigation, search
This article is part of the Tips & Tricks series.
Terminals / Shells Network X Window System Portage System Filesystems Kernel Other

Contents

[edit] Introduction

This guide is appropriate at least for baselayout-1.12.9 which was stable at time of writing. FQDN stands for 'Fully-Qualified Domain Name'.

For the purposes of this guide I will use the example "examplehost.exampledomain.tld" which should be replaced by your own hostname and domainname.

[edit] Removing any obsolete config files

First you should remove any old configuration files which might take precedence over the ones we are about to setup. To do this run:

# rm /etc/hostname
# rm /etc/conf.d/domainname

NOTE: If you leave /etc/hostname present it WILL cause the following settings to fail

[edit] Adding Hostname to /etc/conf.d/hostname

You need to take the hostname for your machine (the bit which appears before the first '.' usually) and put it in the hostname file. You have to edit /etc/conf.d/hostname so it is similar to the following:

File: /etc/conf.d/hostname
HOSTNAME="examplehost"

[edit] Adding Domainname to /etc/conf.d/net

Next take the domain name (the rest of it after the first '.' usually) and put it in the network config file. You need to edit /etc/conf.d/net and add the following (making sure it is the only line beginning with dns_domain :

File: /etc/conf.d/net
dns_domain="exampledomain.tld"

[edit] Modifying the Hosts file

Finally modify /etc/hosts to be able to resolve the hostname of the box without it being online: To do this make sure the line beginning 127.0.0.1 has entries similar to the following

File: /etc/hosts
127.0.0.1       examplehost.exampledomain.tld examplehost localhost.localdomain localhost 

Note: The FQDN (examplehost.exampledomain.tld) is the first part of the line.

[edit] Verifying Changes

Simply log out and it should show the updated system name.

This is examplehost.exampledomain.tld (Linux x86_64 2.6.20-ck1) 21:45:49

Note: You may have to run

# /etc/init.d/hostname restart

for the changes to take effect.

Personal tools