- Как установить доменное имя в GNU /Linux?
- 3 ответа
- Установить FQDN
- активировать имя хоста
- добавить имя домена и адрес на сервер
- VERIFY
- domainname Command in Linux With Examples
- Как правильно установить имя хоста и доменное имя?
- How to setup domain name in Linux server
- Step 1.
- Step 2.
- Step 3.
- Step 4.
- domainname(1) — Linux man page
- Synopsis
- Description
- Get Name
- Set Name
- the Fqdn
Как установить доменное имя в GNU /Linux?
Аналогично имени хоста, которое можно изменить по-разному:
- временно используя команду hostname
- с помощью /etc/hostname (или /etc/sysconfig/network или /etc/HOSTNAME , эти файлы используются сценариями инициализации)
Я хочу изменить свое доменное имя. Я могу использовать команду domainname , но есть ли способ сделать ее постоянной при перезагрузках? Я думаю, что его можно настроить в /etc/resolv.conf , но этот файл обычно генерируется, и я точно не знаю разницу между search и domain . И в какое время именно информация передается программе domainname для установки имени домена?
У вас есть идеи по этому поводу?
Я хотел бы быть в основном совместимым между дистрибутивами. Поэтому, если у кого-то есть указатели на разные дистрибутивы, я с радостью принимаю их.
3 ответа
Установить FQDN
Я использую Debian 7, и это то, что сработало для меня; благодаря Фернандо Рибейру .
sudoedit /etc /hostname
активировать имя хоста
sudo hostname -F /etc /hostname
добавить имя домена и адрес на сервер
VERIFY
Когда вы используете системы redhat-base , linux использует /etc/sysconfig/network , и вы должны установить переменную HOSTNAME в FQDN , когда вы используете FQDN , linux сам определяет имя домена.
Но когда вы используете системы debian-base , вы должны заполнить /etc/hostname с помощью FQDN :
ПРИМЕЧАНИЕ: , если вы хотите установить domain name обязательно установите FQDN (Полностью Qualyfied Domain Name)
Когда вы установите, hostname -d показывает вам domain name .
man hostname , процитированный от конца до начала
Я бы сказал, что он полностью описывает все это.
Источник
domainname Command in Linux With Examples
domainname command in Linux is used to return the Network Information System (NIS) domain name of the host. You can use hostname -d command as well to get the host domainname. If the domain name is not set up in your host then the response will be “none”.
In the networking terminology, the domain name is the mapping of IP with the name. Domain names are registered in the DNS server in case of a local network. If the DNS server is not present you can put the entry in /etc/hosts file to map IP address with the domain name.
Syntax:
Options:
- domainname -h : It is used to display all the options and syntax of the command.
domainname -a or –alias : It is used to display the alias name. Returns blank line if alias name is not set up.
In the below example, you can see initially ‘none’ domainname was returned but after setting up command returns the new name.
domainname -s or –short : Displays the short hostname.
domainname -I or –all-ip-addresses : Used to displays all IP addresses assigned to the host, use ip -a command to check IP addresses.
domainname -i or –ip-address : Displays the localhost address.
domainname -y or –yp or –nis : Displays the Network Information System (NIS) domain name.
In this example you can see, the displayed domain name is the same as we set up using -b option.
Other Useful Options:
- -d, –domain Displays the domain name of DNS.
- -f, –fqdn, –long Long hostname fully qualified domain name(FQDN).
- -F, –file Read hostname or NIS domain name from given file.
Источник
Как правильно установить имя хоста и доменное имя?
Я арендую сервер под управлением Ubuntu 16.04 в компании, назовем его company.org.
В настоящее время мой сервер настроен так:
- Имя хоста: server737263
- доменное имя: company.org
Вот мое полное доменное имя:
Это не удивительно.
Я также арендую доменное имя, давайте назовем его domain.org . Я хотел бы переименовать мой сервер в server1.domain.org .
Это означает настройку моего имени хоста как server1 и моего имени домена как domain.org .
Как я могу сделать это правильно?
Действительно, справочная страница для hostname не ясна. Для меня по крайней мере:
- При вызове с одним аргументом или с параметром —file команды задают имя хоста или имя домена NIS / YP. hostname использует функцию sethostname (2), в то время как все три доменных имени, ypdomainname и nisdomainname используют setdomainname (2). Обратите внимание, что это действует только до следующей перезагрузки. Отредактируйте / etc / hostname для постоянного изменения.
Полное доменное имя
- Вы не можете изменить полное доменное имя с именем хоста или dnsdomainname.
Так что кажется, что редактирования /etc/hostname недостаточно? Потому что если бы он действительно изменил имя хоста, он изменил бы полное доменное имя. Я также прочитал трюк, чтобы изменить имя хоста с помощью команды sysctl kernel.hostname=server1 , но ничто не говорит о том, правильный ли это путь или уродливый трюк.
Как правильно установить имя хоста?
Как правильно установить доменное имя?
Источник
How to setup domain name in Linux server
Published: September 27, 2017 | Modified: June 20, 2020
Learn how to setup domain names in RedHat, Ubuntu, CentOS, Fedora like Linux servers. Also, see how to verify domain name in Linux and FQDN setup in Linux
Many companies have an internal domain for their IT infrastructure. This needs its servers to be configured with a domain name. This will ensure all servers will have FQDN (Fully Qualified Domain Name). For example, server12 is hostname and server12.kerneltalks.com is its FQDN. In such setup, many tools, monitoring requires servers to be identified by FQDN only.
For such a scenario you have to configure the domain name for your Linux server. We will walk you through steps that need to be taken to the setup domain name on your Linux server.
First of all, check if your server is having domain name already set up or not using below command :
If you get output like above then your server is configured with the domain name. If your output is blank then you have to the setup domain name for your server.
Without further delay lets jump into steps to configure domain name.
Step 1.
How to setup FQDN in Linux?
First thing to be done is add FQDN to your hostname in /etc/hosts file.
To confirm your FQDN, run below command :
Output should be hostname.domain name
Step 2.
Configure domain name in Red Hat RHEL, Fedora and CentOS
Add below line in /etc/sysconfig/network
Add below parameter in /etc/sysctl.conf
Configure domain name in Ubuntu
Edit your hostname (not FQDN) in /etc/hostname file. and restart hostname service. If you see below error :
you can set hostname using :
Once done, confirm normal hostname (using hostname ) and FQDN (using hostname -f )
Step 3.
Add domain in /etc/resolv.conf . This file used for setting nameservers as well.
This addition makes sure that you can resolves hostnames within your domain.
Step 4.
Confirm that changes are working perfectly. Question is how to check the domain name of the Linux server?
Below are the commands to check hostname, FQDN, and domain name of your server.
hostname command shows your server’s hostname. hostname -f shows your FQDN. dnsdomainname command shows your domain name of the server!
Источник
domainname(1) — Linux man page
Synopsis
Description
Get Name
hostname will print the name of the system as returned by the gethostname(2) function.
domainname, nisdomainname, ypdomainname will print the name of the system as returned by the getdomainname(2) function. This is also known as the YP/NIS domain name of the system.
dnsdomainname will print the domain part of the FQDN (Fully Qualified Domain Name). The complete FQDN of the system is returned with hostname —fqdn.
The function gethostname(2) is used to get the hostname. When the hostname -a, -d, -f or -i is called will gethostbyname(3) be called. The difference in gethostname(2) and gethostbyname(3) is that gethostbyname(3) is network aware, so it consults /etc/nsswitch.conf and /etc/host.conf to
decide whether to read information in /etc/sysconfig/network or /etc/hosts
To add another dimension to this, the hostname is also set when the network interface is brought up.
Set Name
Note, that only the super-user can change the names.
It is not possible to set the FQDN or the DNS domain name with the dnsdomainname command (see THE FQDN below).
The host name is usually set once at system startup in /etc/rc.d/rc.inet1 or /etc/init.d/boot (normally by reading the contents of a file which contains the host name, e.g. /etc/hostname).
the Fqdn
Technically: The FQDN is the name gethostbyname(2) returns for the host name returned by gethostname(2). The DNS domain name is the part after the first dot.
Therefore it depends on the configuration (usually in /etc/host.conf) how you can change it. Usually (if the hosts file is parsed before DNS or NIS) you can change it in /etc/hosts.
If a machine has multiple network interfaces/addresses or is used in a mobile environment, then it may either have multiple FQDNs/domain names or none at all. Therefore avoid using hostname —fqdn, hostname —domain and dnsdomainname. hostname —ip-address is subject to the same limitations so it should be avoided as well.
Источник