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.allow」檔案內的主機名稱透過網路連入。若「/etc/hosts.deny」檔案存在,則只會拒絕存在於「/etc/hosts.deny」檔案的主機名稱透過網路連入。若「/etc/hosts.allow」檔案和「/etc/hosts.deny」檔案都存在,只會使用「/etc/hosts.allow」檔案。若「/etc/hosts.allow」檔案和「/etc/hosts.deny」檔案都不存在,則所有主機都允許連入。

「/etc/hosts.allow」設定檔或是「/etc/hosts.deny」設定檔的寫法如下:

服務名稱 : 客戶端主機名稱[:Shell指令]

客戶端主機名稱的寫法規則大致如下:

  • 「.」是第一個字元,判斷結尾是否是同樣的子字串。
  • 「.」是最後一個字元,判斷開頭是否是同樣的子字串。
  • IP位址/網路遮罩

「192.168.1.0/24」子網路的網路遮罩是「255.255.255.0」。

所以答案是選項「A」和選項「D」。