- 論壇徽章:
- 1
|
文檔是前幾天就寫好了的,是寫給用戶的
周五銷售才給用戶,所以前幾天沒發(fā)上了
這個配置對很多兄弟們還時有用的
Configuring TCP Wrappers on UnixWare 7 and OpenServer 5
1. Tcp Wapper基礎(chǔ)知識介紹
Tcp_Wapper是在 Solaris, HP_UX,SCO UNIX以及 Linux中廣泛流行的免費軟件。它被設(shè)計為一個介于外來服務(wù)請求和系統(tǒng)服務(wù)回應(yīng)的中間處理軟件。最常見的用法是與inetd一起使用。當(dāng)Inetd接收到一個外來服務(wù)請求的時候,并不是直接調(diào)用,而是調(diào)用TCP Wrapper(可執(zhí)行文件tcpd),TCP Wrapper根據(jù)這個所請求的服務(wù)和針對這個服務(wù)所定制的存取控制規(guī)則來判斷對方是否有使用這個服務(wù)的權(quán)限,如果有,TCP Wrapper將該請求按照配置文件定義的規(guī)則轉(zhuǎn)交給相應(yīng)的守護進程去處理同時記錄這個請求動作,然后自己就等待下一個請求的處理。
TCP Wrapper機制的主要目的在于,來自客戶端的請求只被允許同一個獨立的守護進程(xinetd)直接通信,而它請求的目標(biāo)服務(wù)被TCP Wrapper包裹起來,這樣就提高了系統(tǒng)的安全性和系統(tǒng)管理的方便性。Tcp wrapper隨著應(yīng)用逐漸成為一種標(biāo)準(zhǔn)的Unix安全工具,成為unix守護程序inetd的一個插件。通過Tcp wrapper,管理員可以設(shè)置對inetd提供的各種服務(wù)進行監(jiān)控和過濾,以保證系統(tǒng)的安全性。
2. Installing TCP Wrappers
UnixWare7.1.1后的版本TCP Wrappers已經(jīng)集成到系統(tǒng)中,不需要單獨安裝,配置即可.
TCP Wrappers on OpenServer 5 systems
a. 獲取 TCP Wrapper package for OpenServer 5 systems from:
http://ftp.porcupine.org/pub/security/tcp_wrappers_7.6.tar.gz
b. 因為OSR5下的TCP Wrappers是原程序代碼.故OSR5 系統(tǒng)必須安裝開發(fā)環(huán)境才能完成編譯,安裝步驟不做具體描述了.
c. 拷貝原文件到本地路經(jīng).解壓縮
#gunzip tcp_wrappers_7.6.tar.gz
#tar xvf tcp_wrappers_7.6.tar
編譯源程序
make REAL_DAEMON_DIR=/etc sco-os5
d. 拷貝生成命令到系統(tǒng)/etc目錄
#cp tcpd /etc/tcpd tcpd是所有internet服務(wù)的主要訪問控制守護進程
#cp tcpdchk /etc/tcpdchk 一個檢查 tcpd wrapper 設(shè)置和提供錯誤信息
#cp tcpdmatch /etc/tcpdmatch 用來預(yù)知 tcp wrapper 如何控制一個服務(wù)的特殊請求
注意:還有其它命令可用,這里不一一列舉.具體可上網(wǎng)查詢.
3. Configuring TCP Wrappers
(1) On the OpenServer 5 system
a. 配置inetd網(wǎng)絡(luò)守護進程
inetd.conf是inetd守護進程的配置文件。inetd.conf文件告訴inetd守護進程監(jiān)聽哪些網(wǎng)絡(luò)端口,為每個端口啟動哪個服務(wù)。如果我們要想將telnet、ftp 交由tcpd管控,需要修改/etc/inetd.conf。
would be changed to:
#ftp stream tcp nowait root /etc/ftpd ftpd –a (修改前)
ftp stream tcp nowait root /etc/tcpd ftpd –a (修改后)
#telnet stream tcp nowait NOLUID /etc/telnetd telnetd (修改前)
telnet stream tcp nowait NOLUID /etc/tcpd telnetd (修改后)
修改后重新啟動網(wǎng)絡(luò)守護進程。
kill -HUP $(cat /etc/inetd.pid)
b. 配置訪問控制
/etc/hosts.allow 定義計算機允許的訪問
/etc/hosts.deny 定義指定應(yīng)該拒絕的連接
注意:如果某個系統(tǒng)同時出現(xiàn)在兩個文件里,hosts.allow是優(yōu)先的。另外,如果運行最嚴(yán)格的TCP Wrappers安全,用戶可以在/etc/hosts.deny文件力包含一行“ALL:ALL”,它會禁止所有由TCP Wrappers處理的輸入訪問。然后用戶就可以在/etc/hosts.allow里為特定客戶程序打開服務(wù)程序的端口。
/etc/hosts.allow和/etc/hosts.deny的格式是完全一樣的,當(dāng)然同樣的項目在兩個文件中具有相反的作用。這些項目的基本格式是:
Service-names :client-list [:shell-command]
我們這里只測試管理telnetd和ftpd兩個服務(wù)進程,請看如下兩個文件:
# vi /etc/hosts.allow
telnetd:202.96.1.140 202.96.5.129:allow
ftpd:202.96.5. EXCEPT 202.96.5.140 202.96.5.129:allow
注:telnetd行告訴TCP wrappers接受來自于202.96.5.140和202.96.5.129機器的telnet連接.
ftpd行告訴TCP wrappers接受來自于202.96.5網(wǎng)段中除202.96.5.140和202.96.5.129之外的所有計算機的FTP連接.
#vi /etc/hosts.deny
telnetd:all:deny
ftpd:all:deny
注:禁止所有telnet、ftp未經(jīng)TCP Wrappers處理的訪問
(2) On the UnixWare7 system
a. UW7系統(tǒng)已經(jīng)配置好了TCP Wrappers,我們不需要在配置/etc/inet/inetd.conf.
b. 配置訪問控制
/etc/inet/hosts.allow 定義計算機允許的訪問
/etc/inet/hosts.deny 定義指定應(yīng)該拒絕的連接
文件格式與OSR5相同
Service-names :client-list [:shell-command]
我們這里只測試管理telnetd和ftpd兩個服務(wù)進程,請看如下兩個文件:
#vi /etc/inet/hosts.allow
in.telnetd:202.96.5.140 202.96.5.129.allow
in.ftpd: 202.96.5. EXCEPT 202.96.5.140 202.96.5.129:allow
#vi /etc/inet/hosts.deny
in.telnetd:all:deny
in.ftpd:all:deny
注:寫法內(nèi)容同OpenServer 5.
4. Testing TCP Wrapper configurations
a. On the OpenServer 5 system
# /etc/tcpdchk -v
Using network configuration file: /etc/inetd.conf
>>> Rule /etc/hosts.allow line 1:
daemons: telnetd
clients: 202.96.5.140 202.96.5.129
command: allow
access: granted
>>> Rule /etc/hosts.allow line 2:
daemons: ftpd
clients: 202.96.5. EXCEPT 202.96.5.140 202.96.5.129
command: allow
access: granted
>>> Rule /etc/hosts.deny line 1:
daemons: telnetd
clients: all
command: deny
access: denied
>>> Rule /etc/hosts.deny line 2:
daemons: ftpd
clients: all
command: deny
access: denied
# /etc/tcpdmatch telnetd 202.96.5.140
client: address 202.96.5.140
server: process telnetd
matched: /etc/hosts.allow line 1
command: allow
access: granted
# /etc/tcpdmatch ftpd 202.96.5.129
client: address 202.96.5.129
server: process ftpd
matched: /etc/hosts.deny line 2
command: deny
access: denied
b. On the UnixWare 7 system
# /usr/sbin/tcpdchk -v
Using network configuration file: /etc/inet/inetd.conf
>>> Rule /etc/inet/hosts.allow line 46:
daemons: in.telnetd
clients: 202.96.5.140 202.96.5.129
option: allow
access: granted
>>> Rule /etc/inet/hosts.allow line 47:
daemons: in.ftpd
clients: 202.96.5. EXCEPT 202.96.5.140 202.96.5.129
option: allow
access: granted
>>> Rule /etc/inet/hosts.deny line 46:
daemons: in.telnetd
clients: all
option: deny
access: denied
>>> Rule /etc/inet/hosts.deny line 47:
daemons: in.ftpd
clients: all
option: deny
access: denied
# /usr/sbin/tcpdmatch in.telnetd 202.96.5.140
client: address 202.96.5.140
server: process in.telnetd
matched: /etc/inet/hosts.allow line 46
option: allow
access: granted
# /usr/sbin/tcpdmatch in.ftpd 202.96.5.129
client: address 202.96.5.129
server: process in.ftpd
matched: /etc/inet/hosts.deny line 47
option: deny
access: denied
5. 上面介紹只是TCP Wrapper一些簡單功能,它還提供有許多其它特性。
如果想有更強大的功能可參考TCP Wrappers官方網(wǎng)站。
http://www.cert.org/advisories/CA-1999-01.html
6. 已測試通過的系統(tǒng)
Openserver 5.0.6 5.0.7
UnixWare 7.1.1 7.1.4 |
|