基本處理過程
ldd 可執行工具路徑|grep libwrap
[root@natsha ~]# ldd /usr/sbin/sshd |grep libwrap
libwrap.so.0 => /lib64/libwrap.so.0 (0x00007f97ecca5000)
在/etc/hosts.allow和/etc/hosts.deny檔案定義規則的方法採用以下格式:
daemon_list@host: client_list [ :options :option… ]
服務:客戶端 [:選項]
後台程序應該是服務的可執行工具名
例如:telnet-server服務的可執行工具是in.telnetd,因此在/etc/hosts.allow及/etc/hosts.deny中應該寫in.telnetd,而不是telnet或telnetd。
單一主機:ip
指定網段:ip/24
指定dns字尾:example.com
指定fqdn:client.example.com
指定所有客戶端:all
需要阻止操作時,直接在/etc/hosts.allow中使用deny動作。
選項中其他引數
a、執行外部命令
sshd,in.telnetd:192.168.111.:spawn echo "`date +'%%f %%t'` login from client\: %c to %d">>/var/log/tcpwrap.log
%c 訪問的客戶端資訊(user@host)
%s 訪問的伺服器端資訊(server@host)
%h 訪問的客戶端的fqdn(如果可以dns反向解析)
%p 伺服器pid
b、 排除
在/etc/hosts.allow和/etc/hosts.deny中指定客戶端時,可使用except引數在乙個範圍內排除指定客戶端。
#禁止172.16.0.0/16網路訪問我,排除172.16.100.0/24和172.16.100.1之外
vsftpd: 172.16. except 172.16.100.0/24 except 172.16.100.1
如果同時在「hosts.allow」與「hosts.deny」配置了某個相反的限制,那麼最終以哪乙個檔案為準呢?
4、配置例項
#僅僅僅僅允許192.168.1.0/24的主機訪問sshd
vim /etc/hosts.allow
sshd: 192.168.1.0
vim /etc/hosts.deny
sshd: all
只允許192.168.1.0/24的主機訪問telnet和vsftpd服務
/etc/hosts.allow
vsftpd,in.telnetd: 192.168.1.
/etc/host.deny
vsftpd,in.telnetd: all
另外:
deny 主要用在/etc/hosts.allow定義「拒絕」規則
如:vsftpd: 172.16. :deny
allow 主要用在/etc/hosts.deny定義「允許」規則
如:vsftpd:172.16. :allow
linux防火牆之iptables
linux防火牆基礎 linux系統的防火牆體系基於核心編碼實現,具有非常穩定的效能和極高的效率。通常net filter和iptables都是用來指linux防火牆。兩者的區別 net filter屬於 核心態 的防火牆體系 iptables屬於 使用者態 的防火牆管理體系 iptables的表,...
linux防火牆之firewalld
3 firewalld 區域的概念 4 firewalld資料處理流程 二 firewalld防火牆的配置 4 服務管理 5 埠管理 firewalld和iptables都是用來管理防火牆的工具 屬於使用者態 來定義防火牆的各種規則功能 firewalld提供了支援網路區域所定義的網路鏈結以及介面安...
linux防火牆之firewalld
firewalld防火牆為了簡化管理,將所有網路流量分為多個區域 zone 然後根據資料報的源ip位址或傳入的網路介面等條件將流量傳入相應區域。每個區域都定義了自己開啟或者關閉的埠和服務列表。區域作用 trusted 信任區域 允許所有的傳入流量 一般用於內網之中 public 公共區域 允許與ss...