剛試了一下,我的筆電 IP 為 192.168.1.34/24,Linux 主機 IP 為 192.168.1.1/24
/etc/hosts.allow(deny) 這兩個檔案裡頭原本都沒規則,接著我把以下這行加到 /etc/hosts.deny 並將我的筆電的 IP 改為 192.168.1.35
代碼:
sshd: ALL EXCEPT 192.168.1.34
然後開兩次 Putty 嘗試連接到 Linux 主機,
兩次都 timeout 也沒出現 login 畫面,接著把筆電 IP 改回 192.168.1.34 並連上 Linux 主機看 log
代碼:
[jiunyu:~] $ sudo logwatch --detail low --service sshd --range today
################### Logwatch 7.4.0 (05/02/12) ####################
Processing Initiated: Fri Oct 3 11:43:15 2014
Date Range Processed: today
( 2014-Oct-03 )
Period is day.
Detail Level of Output: 0
Type of Output/Format: stdout / text
Logfiles for Host: EPC
##################################################################
--------------------- SSHD Begin ------------------------
Users logging in through sshd:
jiunyu:
192.168.1.34: 3 times
Refused incoming connections:
192.168.1.35 (192.168.1.35): 2 Time(s)
---------------------- SSHD End -------------------------
###################### Logwatch End #########################
可以看到被擋下來的那兩次也出現在 log 裡,所以應該是 logwatch 會把被擋下來的也一併列出來,封包並沒有通過 tcp wrapper 跑到 sshd 那裡
