1、netperm-table
这是防火墙工具箱里所有东西——netacl,smap,ftp-gw,tn-gw,plug-gw等的配置文件,当一个应用被启动时,它就会从netperm-table中读取出自己相关的配置和许可信息的策略文件。下面把默认安装后的netperm-table贴出来——它有许多注解的
#
#netperm配置表的示例文件
#
#要更好地利用地这个netperm-table,最好把你的主机名用IP地址来替代
#(e.g.;666.777.888),这样比较不容易受到DNS欺骗的侵害。
#
#netacl示例规则:
#---------------------
#下面两行的注释如果去掉,将启动telnet
#netacl-telnetd:permit-hosts127.0.0.1-exec/usr/libexec/telnetd
#netacl-telnetd:permit-hostsYOURADDRESS198.6.73.2-exec/usr/libexec/telnetd
#
#下面这行是tn-gw的
#netacl-telnetd:permit-hosts*-exec/usr/local/etc/tn-gw
#
#下面是rlogin
#netacl-rlogind:permit-hosts127.0.0.1-exec/usr/libexec/rlogind-a
#netacl-rlogind:permit-hostsYOURADDRESS198.6.73.2-exec/usr/libexec/rlogind -a
#
#rlogin-gw的配置
#netacl-rlogind:permit-hosts*-exec/usr/local/etc/rlogin-gw
#
#要将finger使能,把下面两行的注释去掉
#netacl-fingerd:permit-hostsYOURNET.*-exec/usr/libexec/fingerd
#netacl-fingerd:permit-hosts*-exec/bin/cat/usr/local/etc/finger.txt
#smap规则示例:
#-------------------
smap,smapd:userid6
smap,smapd:directory/var/spool/smap
smapd:executable/usr/local/etc/smapd
smapd:sendmail/usr/sbin/sendmail
smap:timeout3600
#ftpgateway规则示例:
#--------------------------
#ftp-gw:denial-msg/usr/local/etc/ftp-deny.txt
#ftp-gw:welcome-msg/usr/local/etc/ftp-welcome.txt
#ftp-gw:help-msg/usr/local/etc/ftp-help.txt
ftp-gw:timeout3600
#uncommentthefollowinglineifyouwantinternaluserstobe
#abletodoFTPwiththeinternet
#ftp-gw:permit-hostsYOURNET.*
#uncommentthefollowinglineifyouwantexternaluserstobe
#abletodoFTPwiththeinternalnetworkusingauthentication
#ftp-gw:permit-hosts*-authall-log{retrstor}
#telnetgateway规则示? br> #-----------------------------
#tn-gw:denial-msg/usr/local/etc/tn-deny.txt
#tn-gw:welcome-msg/usr/local/etc/tn-welcome.txt
#tn-gw:help-msg/usr/local/etc/tn-help.txt
tn-gw:timeout3600
tn-gw:permit-hostsYOURNET.*-passok-xok
#ifthislineisuncommentedincomingtrafficispermittedWITH
#authenticationrequired
#tn-gw:permit-hosts*-auth
#rlogingateway规则:
#-----------------------------
#rlogin-gw:denial-msg/usr/local/etc/rlogin-deny.txt
#rlogin-gw:welcome-msg/usr/local/etc/rlogin-welcome.txt
#rlogin-gw:help-msg/usr/local/etc/rlogin-help.txt
rlogin-gw:timeout3600
rlogin-gw:permit-hostsYOURNET.*-passok-xok
#ifthislineisuncommentedincomingtrafficispermittedWITH
#authenticationrequired
#rlogin-gw:permit-hosts*-auth-xok
#authserverandclient的规则示例
#------------------------------------
authsrv:hosts127.0.0.1
authsrv:database/usr/local/etc/fw-authdb
authsrv:badsleep1200
authsrv:nobogustrue
#clientsusingtheauthserver
*:authserver127.0.0.17777
#X代理的规则:
tn-gw,rlogin-gw:xforwarder/usr/local/etc/x-gw
一头雾水是吧……我来归结一下……
a.每一条规则都是按照要使用该规则的程序的名字开头,后跟一个冒号,当程序读取时也只读取其相关的规则。
b.多个应用可以共用一条规则,各应用名字用逗号隔开或者用星号来通配——当然我不建议你这么做,这样简单是简单了,但维护或者阅读起来会比较烦。
不多说了,在各种服务中再慢慢谈配置吧。
2、netacl
这里我示例配置用netacl包装telnet以及ftp守护程序首先我们在/etc/inetd.conf里添上下面两行——记得吗,前边我们disable了它们了;)
ftpstreamtcpnowaitroot/usr/local/etc/netaclin.ftpd
telnetstreamtcpnowaitroot/usr/local/etc/netaclin.telnetd
这根据你自己的不同来决定,比如你的守护进程是ftpd和telnetd,把in.ftpd及in.telnetd改成它们好了。然后ps-ef|grep inetd找出进程号后发送HUP信号重启。
修改/usr/local/etc/netperm-table中相关条目如下:
#telnetrules:
netacl-in.telnetd:permit-hosts192.168.0.1-exec/usr/sbin/in.telnetd
#这里我只允许从192.168.0.1这台机器telnet上来,所以连localhost都不行:)
netacl-in.telnetd:deny-hostsunknow
#要注意这条信息哦,这是防止网络中恶意用户的IPspoof的办法
#这样,你就可以让地址192.168.0.2telnet到你机器上,而除了它之外的所有地址
#会被显示一条警告信息。最后一条保证了如果你主机的IN.APPR.ARPA反向DNS查询主机
#名错误的时候,该不知名的远程机器无法telnet进来。(DNSspoof)
netacl-in.telnetd:permit-hosts*-exec/bin/cat/usr/local/etc/notelnet.txt
#这条会在不允许登陆时显示一条信息——你可以自己编辑内容。
#
#FtpRules:
netacl-in.ftpd:permit-hosts127.0.0.1-exec/usr/sbin/in.ftpd
#这条只允许本地机器localhost的ftp其它都被拒绝
netacl-in.ftpd:permit-hosts*-exec/bin/cat/usr/local/etc/noftp.txt
#对被拒绝的机器显示这一信息
OK,现在我们来测试一下我们的配置是否正常工作……
我从192.168.0.1上telnet目标机器192.168.0.2
SunOS5.7
login:ronin
Password:
Lastlogin:SatJun1018:00:34from192.168.0.1
SunMicrosystemsInc.SunOS5.7GenericOctober1998
Cracker%
唔,正常得很,看看阻塞的规则是否工作吧,我们就从localhosttelnet本地吧……
Cracker%telnetlocalhost
Trying127.0.0.1...
Connectedtolocalhost.
Escapecharacteris^].
hereisnotelnet.txtfile,meansyoucantaccessthishost.$#@60;---我的notelnet.txt内容
Connectionclosedbyforeignhost.
Cracker%
FTP的测试也是类似的,就不再多说了……
总结netacl的规则有如下表达:
permit-hostip/hostname指定允许主机
deny-hostip/hostname指定拒绝主机,被拒绝的主机会被syslogd记录
-execexecutable[args]为处理服务而激活的程序
-useruserid程序启动时的身份——以root或者nobody等等
-chrootrootdir标识在调用服务程序前的chroot目录


