如何在 ubuntu 中更改 FQDN

如何在 ubuntu 中更改 FQDN

我尝试使用并更改 Ubuntu 中的 FQDN,sudo -i gedit /etc/hosts如下所示:

127.0.0.1   localhost
127.0.1.1   ubuntu.example.com
192.168.217.129 ubuntu.example.com

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

之后我尝试过:

hostname -f 

这表明:

hostname: Name or service not known

我如何更改 FQDN?

答案1

编辑/etc/hostname并放置ubuntu

echo "ubuntu" > /etc/hostname

hostname按照以下格式输入/etc/hosts

IP  fqdn   hostname

/etc/hosts应该看起来像

  127.0.0.1   localhost
  127.0.1.1   ubuntu.example.com  ubuntu
  192.168.217.129 ubuntu.example.com  ubuntu 
# The following lines are desirable for IPv6 capable hosts

相关内容