| 知乎專欄 | 多維度架構 | 微信號 netkiller-ebook | QQ群:128659835 請註明“讀者” |
目錄
# cat -n /etc/hosts
1 # Do not remove the following line, or various programs
2 # that require network functionality will fail.
3 127.0.0.1 development.domain.org development netkiller.localdomain netkiller
4 ::1 localhost6.localdomain6 localhost6
# cat /etc/hostname web1.example.com
查看IP地址
[root@localhost ~]# hostname --ip-address ::1 127.0.0.1
[root@netkiller ~]# hostnamectl
Static hostname: netkiller.localdomain
Icon name: computer-desktop
Chassis: desktop
Machine ID: 072e88a0fdd2447296554f3cd5129076
Boot ID: a978056f50544355abd723b328a89b6f
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-229.el7.x86_64
Architecture: x86_64
設置 hostname
[root@netkiller ~]# hostnamectl set-hostname master
解析順序配置檔案
[root@development bin]# cat /etc/host.conf order hosts,bind
首先在/etc/hosts檔案中尋找,如果不存在,再去DNS伺服器中尋找
IP地址後面TAB符,然後寫主機地址
127.0.0.1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6 192.168.1.10 development.example.com development