linux設置允許和禁止訪問的IP host.allow 和 host.deny
- 2019 年 10 月 10 日
- 筆記
linux設置允許和禁止訪問的IP host.allow 和 host.deny
對於能過xinetd程式啟動的網路服務,比如ftp telnet,我們就可以修改/etc/hosts.allow和/etc/hosts.deny的配製,來許可或者拒絕哪些IP、主機、用戶可以訪問。 比如我們在 /etc/hosts.allow中加入 all:218.24.129. 這樣就會允許來自218.24.129.*域的所有的客戶來訪問。這只是舉個例子,實際上,系統默認狀態 下,都是能用這些網路服的 如果我們在 /etc/hosts.deny中加入,就限制了來自218.24.129.*域的所有的所有的IP。 all:218.24.129. 如果我們在 /etc/hosts.deny中加入 all:218.24.129.134,這樣就限制了所有在218.24.129.134中的所有的用戶的訪問。 當hosts.allow和 host.deny相衝突時,以hosts.allow設置優化。 設置好後,要重新啟動 # /etc/rc.d/init.d/xinetd restart # /etc/rc.d/init.d/network restart
不是任何服務程式都能使用TCP_wrappers的,例如使用命令ldd /usr/sbin/sshd,如果輸出中有libwrap,則說明可以使用TCP_wrappers, 即該服務可以使用/etc/hosts.allow和/etc/hosts.deny,如果輸出沒有libwrap則不可使用
(adsbygoogle = window.adsbygoogle || []).push({});