- 论坛徽章:
- 0
|
[实战solaris之tcp_wrappers安装、配置]
一、摘要
实战solaris之tcp_wrappers安装,/etc/hosts.allow、/etc/hosts.deny。
TCP Wrappers 在 Unix 或 Linux 世界中已经使用了很多年。 它是用限制远端的IP Address权限,和是否能够获得基于TCP的服务。 telnetd 和 ftpd 都是 TCP services,。 有了 TCP Wrappers,你就可以控制那些IP Address可以使用 telnetd 服务,和那些不可以。 在沒有 ssh 之前,TCP Wrappers 可说是唯一的保障系统安全的方法。
由 Solaris 9 开始,TCP Wrappers已经开始加入到系統中。对inetd为基础的服务进行保障,但系统设置没有打开该功能。所以,你如果需要这个TCP Wrappers功能,你便需要人手打开TCP Wrappers对那一个TCP Services产生作用。
TCP Wrappers 的 IP限制规则,是通过 /etc/hosts.allow 和 /etc/hosts.deny 来决定。
要了解更多 TCP Wrappers 的 IP限制规则的方法,可在 Solaris 系統中,输入以下指令:
$ man -M /usr/sfw/man -s 4 hosts_access
二、正文
1.下载tcp_wrappers软件包
url:
http://www.freesunware.com
tcp_wrappers-7.6-sol9-sparc-local
2.安装
# pkgadd -d tcp_wrappers-7.6-sol9-sparc-local
下列软件包是可以使用的:
1 SMCtcpdwr tcp_wrappers
(sparc) 7.6
选择你要执行的软件包(或选择'全部'执行所有的软件包). (default: all) [?,??,q]:
处理软件包范例来自
tcp_wrappers
(sparc) 7.6
试图安装同已经安装的软件包具有相同的 结构和版本号的软件包.这次安装将会
覆盖这个已经安装的包.
Wietse Venema
使用作为包的基本目录
## 正在处理软件包信息.
## 正在处理系统信息.
30软件包路径名已经正确地安装
## 检查磁盘空间需求
## 检查同已经安装的软件包之间的冲突.
## 检查setuid/setgid程序。
安装tcp_wrappers成为
##正在安装1部分- 1.
[ 确认类别 ]
安装成功
3.配置
a) solaris 9以前版本
配置ssh。
#vi /etc/hosts.allow
sshd:10.10.6.,10.10.10.21:ALLOW
#vi /etc/hosts.deny
sshd:ALL:DENY
#ps -ef|grep inetd
root 134 1 0 7月 15 ? 0:00 /usr/sbin/inetd -s
root 29021 28951 0 15:36:46 pts/9 0:00 grep inetd
#kill -HUP 134
或者
#/etc/init.d/inetsvc stop
#/etc/init.d/inetsvc start
配置telnet
#vi /etc/inetd.conf
#telnet stream tcp6 nowait root /usr/sbin/in.telnetd in.telnetd
telnet stream tcp6 nowait root /usr/local/bin/tcpd in.telnetd
#vi /etc/hosts.allow
in.telnetd:10.10.6.,10.10.10.21:ALLOW
sshd:10.10.6.,10.10.10.21:ALLOW
#vi /etc/hosts.deny
in.telnetd:ALL:DENY
sshd:ALL:DENY
b)Solaris 10
Solaris 10 以前的版本:
Soalris 10 和 Solaris 9或以前的版本,启动 TCP Wrappers 方法是有很大的分別。
Solaris 9或以前的版本如果需要启动 TCP Wrappers,就必须要修改 /etc/inetd.conf 来达到目标
Service Management Facility(SMF)
Solaris 10 已经开始使用 Service Management Facility (SMF) 来代替修改 inetd.conf 来管理 TCP Service。所以,如果你已前习惯了修改 inetd.conf 来控制 daemon 的运作的话,在使用 Solaris 10 后你可能会觉得很难使用。 新的方法可以使用 inetadm 來处理 deamon的运作
Inetdadm的简单介绍
检查daemon(services)是否安装或启动
旧版本 Solaris
Solaris 10
编辑 /etc/inetd.conf 来检查安装了什么daemon和启动了什麼 daemon
执行 inetadm 便可检查安裝了什么 services 和启动了什么 services
执行 inetadm -l 便可以了解该 services 的详细资料。 e.g. : inetadm -l telnet
svcadm 的简单介紹:
停止 Telnetd service 运行:
旧版本 Solaris
Solaris 10
编辑 /etc/inetd.conf
把要停用的 services 前加上一個 # 号
telnet stream tcp6 nowait root /usr/sbin/in.telnetd in.telnetd
改成
#telnet stream tcp6 nowait root /usr/sbin/in.telnetd in.telnetd
离开编辑并存档
执行行 /etc/init.d/inetsvc restart
$ inetadm | grep telnet
enable online svc:/network/telnet:default
$ svcadm disable network/telnet
开启 Telnetd service 運作:
旧版本 Solaris
Solaris 10
编辑 /etc/inetd.conf
把要启用的 services 前的 # 号刪去
#telnet stream tcp6 nowait root /usr/sbin/in.telnetd in.telnetd
改成
telnet stream tcp6 nowait root /usr/sbin/in.telnetd in.telnetd
离开并存档
执行 /etc/init.d/inetsvc restart
$ inetadm | grep telnet
enable online svc:/network/telnet:default
$ svcadm enable network/telnet
设定Telnetd 使用 TCP Wrappers:
以下例子,將会說明如何使用 TCP Wrappers 在 telnetd 上,並且使用 SMF 來操作。
如果要了解更多TCP Wrappers在Solaris 10上的其它操作資料,可參考附录2
1. 查询 Telnetd 的 services 全名。
$ inetadm | grep telnet
enabled online svc:/network/telnet:default
services 名为 network/telnet
2. 检查 telnet 的 tcp_wrappers 功能是否开启,如果是FALSE就代表还未开放。
$ inetadm -l telnet | grep tcp_wrappers
tcp_wrappers=FALSE
3. 开启 telnet 的 tcp_wrappers 功能。
$ inetadm -m telnet tcp_wrappers=TRUE
4. 再检查 telnet 的 tcp_wrappers 功能是否开启,如果是TRUE就代表已经开启。
$ inetadm -l telnet | grep tcp_wrappers
tcp_wrappers=TRUE
5. 检查 telnetd 的执行程式名称。
$ inetadm -l telnet | grep exec
exec="/usr/sbin/in.telentd"
执行程式为 in.telentd
6. 建立 /etc/hosts.deny,用來拒绝任何人使用 telnet services,否则你还是可以 telnet 进去 server里。
hosts.deny 是 TCP Wrappers 设定档,用来设定那些services需要拒绝 。
备注: ::DENY
编辑 /etc/hosts.deny,并把 in.telnetd 加进去。
in.telnetd:ALL:DENY
离开并存档
7. 建立 /etc/hosts.allow,用来允许某些 IP 可以使用 telnet services,否则你便不可以 telnet 进去 server里。
hosts.allow 是 TCP Wrappers 设定档,用來设定某些IP允许使用某些services 。
备注: ::ALLOW
以下例子,将会允许 202.134.101.110 和 192.168.30.1 至 192.168.30.255 使用 telnet services。
编辑 /etc/hosts.allow,并把 in.telnetd 加进去。
in.telnetd:202.134.101.110:ALLOW
in.telnetd:192.168.30.0/255.255.255.0:ALLOW
离开并存档
设定已经完成,你可以开始测试 Telnet 功能了。
附录 1
/etc/inet/inetd.conf
ftp stream tcp nowait root /usr/sbin/in.ftpd in.ftpd
改为
ftp stream tcp nowait root /usr/sbin/tcpd /usr/sbin/in.ftpd
telnet stream tcp nowait root /usr/sbin/in.telnetd in.telnetd
改为
telnet stream tcp nowait root /usr/sbin/tcpd /usr/sbin/in.telnetd
附录 2
[Example]/etc/hosts.allow
in.telnetd:202.66.202.:ALLOW
in.ftpd:202.66.202.:ALLOW
[Example] /etc/hosts.deny
in.telnetd:ALL:DENY
in.ftpd:ALL:DENY
重新启动 inetd daemon
# /etc/init.d/inetsvc stop
# /etc/init.d/inetsvc start
附录 3
This content is submitted by a BigAdmin user. It has not been reviewed for technical accuracy by Sun Microsystems, though it may have been lightly edited to improve readability. If you find an error or would like to comment on the article, please contact the submitter or use the comment field at the bottom of the article. Community submissions may not follow Sun trademark guidelines. For information on Sun trademarks, please see
http://www.sun.com/suntrademarks/
.
Enabling TCP Wrappers in the Solaris 10 Operating System
作者:
Andrew Choi (蔡健發)
Glenn Brunette, April, 2005
First let's first provide a little background. TCP Wrappers has been around for many, many years (see
Wietse Venema's FTP archive
). It is used to restrict access to TCP services based on host name, IP address, network address, and so on. For more details on what TCP Wrappers is and how you can use it, see tcpd(1M). TCP Wrappers was integrated into the Solaris Operating System starting in the Solaris 9 release, where both Solaris Secure Shell and inetd-based (streams, nowait) services were wrapped. Bonus points are awarded to anyone who knows why UDP services are not wrapped by default.
TCP Wrappers support in Secure Shell was always enabled since Secure Shell always called the TCP Wrapper function host_access(3) to determine if a connection attempt should proceed. If TCP Wrappers was not configured on that system, access, by default, would be granted. Otherwise, the rules as defined in the hosts.allow and hosts.deny files would apply. For more information on these files, see hosts_access(4). Note that this and all of the TCP Wrappers manual pages are stored under /usr/sfw/man in the Solaris 10 OS. To view this manual page, you can use the following command:
$ man -M /usr/sfw/man -s 4 hosts_access
inetd-based services use TCP Wrappers in a different way. In the Solaris 9 OS, to enable TCP Wrappers for inetd-based services, you must edit the /etc/default/inetd file and set the ENABLE_TCPWRAPPERS parameter to YES. By default, TCP Wrappers was not enabled for inetd.
In the Solaris 10 OS, two new services were wrapped: sendmail and rpcbind. sendmail works in a way similar to Secure Shell. It always calls the host_access function and therefore TCP Wrappers support is always enabled. Nothing else needs to be done to enable TCP Wrappers support for that service. On the other hand, TCP Wrappers support for rpcbind must be enabled manually using the new Service Management Facility (SMF). Similarly, inetd was modified to use a SMF property to control whether TCP Wrappers is enabled for inetd-based services.
Let's look at how to enable TCP Wrappers for inetd and rpcbind.
To enable TCP Wrappers support for inetd-based services, you can simply use the following commands:
# inetadm -M tcp_wrappers=true# svcadm refresh inetd
This enables TCP Wrappers for inetd-based (streams, nowait) services like telnet, rlogin, and ftp (for example):
# inetadm -l telnet | grep tcp_wrappers
default tcp_wrappers=TRUE
You can see that this setting has taken effect for inetd by running the following command:
# svcprop -p defaults inetddefaults/tcp_wrappers boolean true
Note that you can also use the svccfg(1M) command to enable TCP Wrappers for inetd-based services.
# svccfg -s inetd setprop defaults/tcp_wrappers=true# svcadm refresh inetd
Whether you use inetadm(1M) or svccfg is really a matter of preference. Note that you can also use inetadm or svccfg to enable TCP Wrappers on a per-service basis. For example, let's say that we wanted to enable TCP Wrappers for telnet but not for ftp. By default, both the global and per-service settings for TCP Wrappers are disabled:
# inetadm -p | grep tcp_wrapperstcp_wrappers=FALSE # inetadm -l telnet | grep tcp_wrappersdefault tcp_wrappers=FALSE # inetadm -l ftp | grep tcp_wrappersdefault tcp_wrappers=FALSE
To enable TCP Wrappers for telnet, use the following command:
# inetadm -m telnet tcp_wrappers=TRUE
Let's check out the settings again:
# inetadm -p | grep tcp_wrapperstcp_wrappers=FALSE # inetadm -l telnet | grep tcp_wrappers tcp_wrappers=TRUE # inetadm -l ftp | grep tcp_wrappersdefault tcp_wrappers=FALSE
As you can see, TCP Wrappers has been enabled for telnet but none of the other inetd-based services. Pretty cool, eh?
You can enable TCP Wrappers support for rpcbind by running the following command:
# svccfg -s rpc/bind setprop config/enable_tcpwrappers=true# svcadm refresh rpc/bind
This change can be verified by running:
# svcprop -p config/enable_tcpwrappers rpc/bindtrue
That is all there is to it! Quick, easy and painless!
![]()
文件:
[HOLER]实战solaris之tcp_wrappers安装.rar
大小:
14KB
下载:
下载
holer
holeryu@hotmail.com
http://holeryu.cublog.cn/
http://blog.csdn.net/holeryu/
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/16991/showart_345787.html |
|