Which /etc/hosts.allow entries will permit access to sshd for users from the 192.168.1.0/24 subnet? (Choose TWO correct answers.)
A. sshd : 192.168.1.
B. sshd : 192.168.1
C. sshd : 192.168.1.0 netmask 255.255.255.0
D. sshd : 192.168.1.0/255.255.255.0
E. sshd : 192.168.1.0
题解
「/etc/hosts.allow」设置档可用来设置允许透过网络连入使用服务的主机。若连入的主机符合「/etc/hosts.allow」文件内的规则,就会被允许连入。若「/etc/hosts.deny」文件存在,则只会拒绝存在于「/etc/hosts.deny」文件的主机名称透过网络连入。若「/etc/hosts.allow」文件和「/etc/hosts.deny」文件都存在,会先检查「/etc/hosts.allow」文件,符合的话就允许连入,不符合的话再检查「/etc/hosts.deny」文件,符合的话就拒绝连入。若「/etc/hosts.allow」文件和「/etc/hosts.deny」文件都不存在,则所有主机都允许连入。
「/etc/hosts.allow」设置档或是「/etc/hosts.deny」设置档的写法如下:
客户端主机名称的写法规则大致如下:
- 「.」是第一个字符,判断结尾是否是同样的子字符串。
- 「.」是最后一个字符,判断开头是否是同样的子字符串。
- IP 地址/网络遮罩
「192.168.1.0/24」子网络的网络遮罩是「255.255.255.0」。
所以答案是选项「A」和选项「D」。
