问题原文
原帖链接 · Mildred · CC BY-SA 3.0
Similarly to hostname that can be changed in different ways:
- temporarily using the
hostnamecommand - permanently using
/etc/hostname(or/etc/sysconfig/networkor/etc/HOSTNAME, these files are used by the init scripts)
I want to change my domain name. I can use the domainname command, but is there a way to make it permanent across reboots? I think it can be configured in /etc/resolv.conf but this file is generally generated and I don't know exactly the difference between search and domain directives. And at what time exactly the information there is passed to the domainname program to set the domain name?
Do you have any ideas on that?
I'd like to be mostly compatible across distributions. So if if anyone has pointers on the different distributions flavours, I'd gladly accept them.
社区高分解答
原帖链接 · jason · CC BY-SA 4.0
Set FQDN
I'm using Debian 7 and this is what worked for me; thanks to Fernando Ribeiro.
sudoedit /etc/hostname
server # here's where you put the server's host name
activate hostname
sudo hostname -F /etc/hostname
add domain name and address to the server
sudoedit /etc/hosts
192.168.1.2 server.domain server
VERIFY
> hostname --short
server
> hostname --domain
domain
> hostname --fqdn
server.domain
> hostname --ip-address
192.168.1.2
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
