What is a fully qualified domain name (FQDN)?

 fully qualified domain name (FQDN) is the complete domain name for a specific computer, or host, on the Internet. The FQDN consists of two parts: the hostname and the domain name. For example, an FQDN for a hypothetical mail server might be mymail.somecollege.edu. The hostname is mymail, and the host is located within the domain somecollege.edu.

In this example, .edu is the top-level domain (TLD). This is similar to the root directory on a typical workstation, where all other directories (or folders) originate. (Within the .edu TLD, Indiana University Bloomington has been assigned the indiana.edu domain, and has authority to create subdomains within it.)

The same applies to web addresses. For example, www.indiana.edu is the FQDN on the web for IU. In this case,www is the name of the host in the indiana.edu domain.

When connecting to a host (using an SSH client, for example), you must specify the FQDN. The DNS server then resolves the hostname to its IP address by looking at its DNS table. The host is contacted and you receive a login prompt.

If you are using only the hostname (without the domain information) to connect to a server, the application you're using may not be able to resolve the hostname. This can happen if either the DNS suffix search order in your computer's TCP/IP properties is incorrect, or the DNS table is corrupted. In these cases, entering the host's FQDN will allow DNS to locate the server. Also, if you are trying to connect to a remote host that is not local to your Internet service provider (ISP), you will probably have to use the FQDN. For example, it's unlikely that a DNS server at IU would have a listing for remote hosts at another university or an unrelated ISP.

FQDN是Fully Qualified Domain Name的缩写, 含义是完整的域名. 例如, 一台机器主机名(hostname)是www, 域后缀(domain)是example.com, 那么该主机的FQDN应该是www.example.com.

题外话, 其实FQDN最后是以"."来结尾的, 但是大部分的应用和服务器都允许忽略最后这个点.

Linux允许用户通过hostname命令查看并设置主机名. 用户也可以通过hostname -f命令得到该主机的FQDN. 但是, 却没有直接设置FQDN的命令.

实际上, 设置Linux的FQDN可以通过两种方法实现.

第一种, /etc/hostname + /etc/hosts文件组合

首先在/etc/hostname文件中设置主机名, 假设是

www

然后在/etc/hosts文件中增加一行主机记录, 第一个字段是该主机的IP地址, 第二个字段是你希望设置的FQDN, 最后是刚刚设置的主机名, 如下

A.B.C.D www.example.com www

设置好之后, 通过hostname -F /etc/hostname更新主机名. 这时, 通过hostname -f看到的FQDN就应该是: www.example.com

第二种, /etc/hostname + /etc/resolv.conf组合

如果Linux不能在/etc/hosts文件中找到hostname对应的记录, 就会试图从resolv.conf文件中得到主机的域名后缀(domain name). 例如, 这样的/etc/resolv.conf文件

domain example.com 
search example.com 
nameserver W.X.Y.Z

根据配置文件中的domain后缀example.com, 加上主机名www, Linux会试图自动拼接成一个候选FQDN:www.example.com. 但这个候选FQDN还需要进一步验证.

Linux通过DNS服务器W.X.Y.Z解析候选FQDN, 如果解析失败, 生成FQDN过程就失败了. 如果解析成功, 则会返回www.example.com这个域名的正式名称. 也就是说, 如果在DNS服务器的记录中, www.example.com这个域名是指向server.example.com的CNAME记录的话, 而server.example.com才是A记录. 返回的FQDN就是server.example.com, 而不是www.example.com.

以上就是Linux下设置FQDN的方法.

FQDN:(Fully Qualified Domain Name)完全合格域名/全称域名,是指主机名加上全路径,全路径中列出了序列中所有域成员。全域名可以从逻辑上准确地表示出主机在什么地方,也可以说全域名是主机名的一种完全表示形式。从全域名中包含的信息可以看出主机在域名树中的位置。DNS解析流程:首先查找本机HOSTS表,有的直接使用表中定义,没有查找网络连接中设置的DNS 服务器由他来解析。

例如,acmecompany公司的Web服务器的全域名可以是 acmecompany.,而若sales主机是在销售部子域,则它的全域名可以是sales.acmecompany。当给出的名字像acmecompany而不是acmecompany.时,他们通常是指主机名,而名字后边带有点号(“.”是指根域名服务器)的则认为是全域名。这种区别在理解和控制解析过程时是非常重要的。点号实际上指出了域名树的根。

全域名在实际中是非常有用的。电子邮件就使用全域名作为收信人的电子邮件地址,如janicejones@ acmecompany. com,其中收信人为janicejones,跟在收信人名字后面是符号@,@后面是邮件服务器的全域名,或者说是邮件服务器所在企业的域名,最后是顶层域名.com。. com意味着acmecompany是一个商业机构。

与URL的区别在于协议头”Http://”。

原文地址:https://www.cnblogs.com/kex1n/p/5177303.html