Linode.com Forum Forum Index Linode.com Forum
Linode Community Forums
 


Machine name versus domain name

Click here to go to the original topic

 
       Linode.com Forum Forum Index -> Linux Networking
Author Message
ux9i



Joined: 04 Mar 2008
Posts: 5

Posted: Tue Mar 18, 2008 11:52 am    Post subject: Machine name versus domain name  

Basic question.

I told my domain hosting provider to use the Linode name server (since I'm using the Dashboard / DNS Manager for DNS management).

Then in DNS manager it points my domain, plus it added the usual other records like www and mail. Everything looks good. Both mydomain, www.mydomain, and mail.mydomain all point to my Linode machine.

Now where exactly does a machine name fit into this? I want it to be myname.mydomain. I would have to add another DNS record for "myname" just like DNS manager added one for "www" and "mail", right?

At that point the machine is legitimate, and I'm not "faking out" the machine name, right? I ask all this because in Fedora Core 8 I added to /etc/sysconfig/network the settings HOSTNAME=myname.mydomain and DOMAIN=mydomain. When the machine reboots, it says hostname is indeed "myname.mydomain" but hostname --fqdn says Unknown host.

Seems like I'm missing something or else making the machine "legitimate" by adding a DNS record for it would keep it happy (for example, ping myname.mydomain would work, Apache would be happy that my machine name resolves to the right IP address in DNS, etc).
Back to top  
Jay



Joined: 14 Nov 2004
Posts: 125
Location: NC, USA

Posted: Tue Mar 18, 2008 11:58 am    Post subject:  

In your /etc/hosts

127.0.0.1 localhost localhost.domain
your.ip myname myname.mydomain.tld

hostname -f uses your /etc/hosts to get the fqdn, so just make sure these are the first two lines in your hosts file and you're good!
Back to top  
ux9i



Joined: 04 Mar 2008
Posts: 5

Posted: Tue Mar 18, 2008 8:51 pm    Post subject:  

After some hours of research, trial, and error, I figured out a more appetizing or perhaps philosophically appealing way to configure a machine name. Please correct me if something here is not quite right.

First, do NOT put your machine name in /etc/hosts. Leave it alone as "127.0.0.1 localhost" and don't add any aliases. (With ipv6 you'll may want "::1 localhost6" too)

Second, do NOT put the domain in /etc/sysconfig/network where you say HOSTNAME=yourmachine. Leave that as the single word machine name, no domain.

Then to expose what's happening in your current setup try this command, and note the result (replace XX and YYY with numbers for your machine):

Code: $ ping liXX-YYY
PING liXX-YYY.members.linode.com (AA.BB.CC.DD) 56(84) bytes of data.

Why did it magically add "members.linode.com"? That's because /etc/resolv.conf has this in it:

Code: ; generated by /sbin/dhclient-script
search members.linode.com
nameserver EE.FF.GG.HH
nameserver ...(etc)...

These values came from DHCP. I'm using the /sbin/dhclient DHCP client. Happily, it can be told to override the domain name handed to you by DHCP. You simply create the file /etc/dhclient-eth0.conf containing only:

Code: supersede domain-name "yourdomain.com";

Next time you restart, you'll see /etc/resolv.conf has the new value

Code: $ cat /etc/resolv.conf
; generated by /sbin/dhclient-script
search yourdomain.com
nameserver EE.FF.GG.HH
nameserver ...(etc)...

If you run hostname, your machine name is truly the short single word "yourmachine". And if you run "hostname --fqdn", your machine name plus true domain is correct "yourmachine.yourdomain.com".

Do "ping localhost" and you goes to 127.0.0.1. Do "ping yourmachine" and it does to the IP AA.BB.CC.DD. Try "ping www" and see it also go to AA.BB.CC.DD since the domain is right and the search suffix has been correctly set.

The last thing to do is add an A record to DNS for "yourmachine", just like there's an A record for "www" and perhaps "mail". Does Bill Gates do "ssh microsoft.com"? Probably there's a machine name in front of the domain. So adding the A record legitimizes that. Now you can finally "ssh yourmachine.yourdomain.com" and it gets to the right place from the outside.

If you add a second machine associated with your domain, this setup continues to work, rather than trying to figure out what to do to ssh or scp files to a particular machine or another. And if you are on one machine on your domain, you can "ssh othermachine" (without domain name) and you are there.
Back to top  
reallove



Joined: 27 Dec 2007
Posts: 8
Location: Cluj-Napoca , Romania

Posted: Thu Mar 20, 2008 5:16 pm    Post subject:  

ux9i wrote: Does Bill Gates do "ssh microsoft.com"? Probably there's a machine name in front of the domain.

<off-topic>
Bill Gates does not ssh microsoft.com,he probabily remote desktop it.
</off-topic>
Back to top  
 
       Linode.com Forum Forum Index -> Linux Networking
Page 1 of 1