linux下tcp wrapper 使用詳解

來源:互聯網
上載者:User

標籤:linux tcp_wrap tcp wrapper

   wrapper是一款存取控制的工具,很類似iptables的功能,但是要比iptables功能要小很多,一般只有在滿足以下條件時才能使用tcp wrapper



    檢查要控制的軟體工具是否支援tcp_wrap: ldd /usr/sbin/sshd(如果有wrap庫代表支援)/ldd `which xinted` | grep libwrap


    wrapper存取控制語句是寫在:/etc/hosts.allows和/etc/hosts.deny 這兩個檔案當中


下面我舉一些例子1:

/etc/hosts.allow---in.telnetd: 192.168. EXCEPT 192.168.77.100(允許192.168.網段的主機訪問EXCEPT 除去192.168.77.100不能訪問)

/etc/hosts.deny---in.telnetd:ALL (allow除外的全部拒絕)--(為什麼後面要加上拒絕所有呢,因為allow檔案中除去的192.168.77.100 不被allow檔案控制匹配,只能讓deny檔案來匹配)

下面我舉一些例子1:

/etc/hosts.allow---in.telnetd:192.168. :spawn echo "you ren fang wen `date`" >> /var/log/tcpwrap.log(這樣的話可以訪問的時候可以記錄到日誌當中)+不記錄ip和訪問的服務

/etc/hosts.allow---in.telnetd:192.168. :spawn echo "`date`,soment login from %c to %s." >> /var/log/tcpwrap.log(這樣的話是記錄用戶端和訪問服務端的IP和服務)

/etc/hosts.allow---in.telnetd:192.168. EXCEPT 192.168.77.100 :spawn echo "`date`,soment login from %c to %s." >> /var/log/tcpwrap.log

/etc/hosts.deny---in.telnetd:ALL :spawn echo "`date`,soment some from %h." >> /var/log/tcpwrap.log (這兩行是記錄錯誤記錄,但是必須allow有拒絕的訪問)

一般tcp_wrap常用的宏(可以直接man 5 hosts_access參考更多的宏):

%c: client information([email protected])

%s: service info ([email protected])

%h: client hostname

%p: server PID


本文出自 “以經驗為參謀” 部落格,請務必保留此出處http://zhangjianxin.blog.51cto.com/10134758/1652786

linux下tcp wrapper 使用詳解

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.