tcp_wrapper 與 xinetd 都是常見的 Linux 網路服務存取控制工具。前者透過 libwrap.so 與 hosts.allow、hosts.deny 進行控制,後者則是超級守護進程,可管理多個非獨立服務。
常見檔案包括:
/etc/hosts.allow /etc/hosts.deny
格式通常為:
daemon_list: client_list :options
例如只允許 172.16 網段使用 sshd:
/etc/hosts.allow sshd:172.16. /etc/hosts.deny sshd:ALL
client_list 可寫成 IP、網段、主機名、網域或 ALL、LOCAL、KNOWN、UNKNOWN、PARANOID 等巨集。
ldd 'which httpd' | grep libwrap strings 'which portmap' | grep hosts
主要設定檔為:
/etc/xinetd.conf /etc/xinetd.d/*.conf
常見控制項目包括:
only_from no_access access_times bind cps per_source instances server_args port
例如限制 rsync 僅監聽特定 IP、限制來源網段並控制同時連線數,可透過 bind、only_from、no_access、cps、per_source 等項目完成。
掌握 tcp_wrapper 與 xinetd 的設定邏輯,有助於在企業環境中實現更細緻的服務訪問控制。