![執行“hostname -i”不再顯示我的所有位址](https://rvso.com/image/885957/%E5%9F%B7%E8%A1%8C%E2%80%9Chostname%20-i%E2%80%9D%E4%B8%8D%E5%86%8D%E9%A1%AF%E7%A4%BA%E6%88%91%E7%9A%84%E6%89%80%E6%9C%89%E4%BD%8D%E5%9D%80.png)
我在 Ubuntu 16.04.1 上更改了主機名稱。
現在,除了一個之外,運行hostname -i
會刪除我的大部分地址。
相反,它的輸出是:
127.0.1.1
它曾經是:ipv6_address%eth0 ipv6_address%eth1 ipv6_address%2 ipv4_address ipv4_address ipv4_address ipv4_address
。
/etc/主機名稱:ubuntu-rany-01
/etc/主機:
# Your system has configured 'manage_etc_hosts' as True.
# As a result, if you wish for changes to this file to persist
# then you will need to either
# a.) make changes to the master file in /etc/cloud/templates/hosts.tmpl
# b.) change or remove the value of 'manage_etc_hosts' in
# /etc/cloud/cloud.cfg or cloud-config from user-data
#
127.0.1.1 rany-01 rany-01
127.0.0.1 localhost
# 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
ff02::3 ip6-allhosts
有什麼辦法可以找找我的地址嗎?
答案1
這是因為/etc/hosts
您在其中找到了該條目127.0.1.1 YourLinuxBoxName
。
DNSmasq 使用此特定的 localhost 項目(127/8
is中的每個位址)。localhost
忽略它是安全的。
答案2
您應該更改下一行:
127.0.1.1 rany-01 rany-01
在/etc/hosts
。一定是:
127.0.1.1 ubuntu-rany-01
/etc/hostname
或者您可以更改:的內容rany-01
而不是ubuntu-rany-01
.