Home | 简体中文 | 繁体中文 | 杂文 | 打赏(Donations) | OSChina 博客 | Facebook | Linkedin | 知乎专栏 | Search | About

14.3. hosts

14.3.1. /etc/hostname

# cat /etc/hostname
web1.example.com
			

14.3.2. hostnamectl - Control the system hostname

[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
			
			
		
# 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

		
		

14.3.3. /etc/host.conf

解析顺序配置文件

[root@development bin]# cat /etc/host.conf
order hosts,bind
			

首先在/etc/hosts文件中寻找,如果不存在,再去DNS服务器中寻找

14.3.4. /etc/hosts

IP地址后面TAB符,然后写主机地址

127.0.0.1       localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
192.168.1.10	development.example.com development
			

14.3.5. hosts.allow / hosts.deny

/etc/hosts.allow 和 /etc/hosts.deny

许可IP/禁止IP,相当于黑白名单

14.3.6. /etc/resolv.conf

			
search example.com
nameserver 208.67.222.222
nameserver 208.67.220.220