五,设置NAT内部的机器:
1,所有内网的主机都应该把FreeBSD的内网ip设置为自己的默认网关。(此段未译,没有必要)
Assume the FreeBSD box NAT/firewall has IP address: 192.168.1.1
AIX: edit /etc/rc.net and add /usr/sbin/route add 192.168.1.1 gateway >>$LOGFILE 2>&1
FreeBSD: edit /etc/rc.conf and add defaultrouter="192.168.1.1"
HP-UX: edit /etc/rc.config.d/netconf and add ROUTE_GATEWAY[0]="192.168.1.1"
Linux Redhat: edit /etc/sysconfig/network and add GATEWAY=192.168.1.1
NetBSD: echo "192.168.1.1" > /etc/mygate
OpenBSD: echo "192.168.1.1" > /etc/mygate
Solaris: echo "192.168.1.1" > /etc/defaultrouter
Win2k: Start-Settings->Control Panel->Network and Dial-up Connections->Local Area Network->
Properties->Internet Protocol (TCP/IP)->Default Gateway->192.168.1.1
如果你不想重启来使默认的网关生效,就用"route"手动添加默认路由:
AIX: route add 0 192.168.1.1
HP-UX: route add 192.168.1.1
FreeBSD,NetBSD,OpenBSD,Solaris: route add default 192.168.1.1
Linux Redhat: route add default gw 192.168.1.1
2,unix客户机需要编辑/etc/resolv.conf加入域名服务器来解析主机名:
UNIX clients:
$ cat /etc/resolv.conf
nameserver
nameserver
Win2k :
Start-Settings->Control Panel->Network and Dial-up Connections->Local Area Network->
Properties->Internet Protocol (TCP/IP)->->Advanced TCP/IP Settings->DNS
and add the ISP DNS IPs.
六,熟悉你的IPFilter:
一旦你的NAT/firewall连接到网上了,你应该开始阅读IPFILTER-HOWTO at http://www.unixcircle.com/ipf/ 并向/etc/ipf.conf加入更多的阻塞/通过规则。一些其他有用的链接可以在www.ipfilter.org上找到。/etc/ipf.conf和/etc/ipnat.conf的每次改变,你都应该做下面这些事。重新加载规则会刷新当前所有活动连接。
# /sbin/ipf -Fa -f /etc/ipf.rules
# /sbin/ipnat -CF -f /etc/ipnat.rules
你可以用ipfstat来显示firewall统计,按"top"的方式:
# /sbin/ipfstat -t
firewall.muine.org - IP Filter: v3.4.27 - state top 23:01:10
Src = 0.0.0.0 Dest = 0.0.0.0 Proto = any Sorted by = # bytes
Source IP Destination IP ST PR #pkts #bytes ttl
192.168.1.200,1415 65.92.100.89,6699 4/4 tcp 8245 6923504 42:14:06
23.234.234.2,24064 208.31.160.30,22 4/4 tcp 576 199843 119:59:59
192.168.1.200,2091 64.124.41.191,8888 4/4 tcp 157 118770 51:36:40
192.168.1.200,1094 64.124.41.161,8888 4/4 tcp 125 94190 46:37:34
查询当前版本:
# /sbin/ipf -V
ipf: IP Filter: v3.4.27 (264)
Kernel: IP Filter: v3.4.27
Running: yes
Log Flags: 0 = none set
Default: block all, Logging: available
Active list: 0
注意内核中IPFILTER_DEFAULT_BLOCK项中的"block all"
显示当前MAP/Redirect filters 和 active sessions的列表:
# /sbin/ipnat -l
在/etc/ipf.conf中为每个规则找到"hit"的统计信息:
# /sbin/ipfstat -hio
查看ipftest(1), mkfilters(1), ipf(4), ipl(4), ipf(8), ipfstat(8), ipmon(8), ipnat(8)的详细信息
七,测试firewall:
为了测试防火墙,下列链接比较有用:
Test the firewall system (http://www.cert.org/security-improvement/practices/p060.html)
Auditing Your Firewall Setup (http://www.enteract.com/~lspitz/audit.html)
On the topic of Firewall Testing (http://web.ranum.com/pubs/fwtest/)
一些对测试有用的工具:
nmap
xprobe
hping2
firewalk
isic
八,服务质量(QoS):
带宽限制:
FreeBSD 可以通过dummynet实现带宽管理。dummynet可以非常有效的将一个可能成为Dos的快速连接降低为一个慢速连接。 man dummynet(4)来获得更多有价值的信息。自从dummynet和ipfw捆绑以来,FreeBSD成为非常有效的防火墙,你可能需要3个ipfw 选项加到内核文件中来捆绑dummynet。
options IPFIREWALL
options IPFIREWALL_VERBOSE
options IPFIREWALL_DEFAULT_TO_ACCEPT
options DUMMYNET
重新编译内核并重启系统。
要使ipfw和dummynet一起工作编辑/etc/rc.conf:
firewall_enable="YES"
firewall_script="/etc/rc.dummynet"
firewall_type="open"
firewall_logging="YES"
假设你有一个快速以太网通道并要将其速度限制到以太网的水平:
在主机192.168.1.4上构造一个通向任何目的地的管道 1
# /sbin/ipfw add 100 pipe 1 ip from 192.168.1.4 to any
将管道速度缩减到10Mbits/s:
# /sbin/ipfw pipe 1 config bw 10Mbit/s
你还可以构造许多不同速度的管道,协议。
删除所有管道:
# /sbin/ipfw flush
为了让上述规则启动,可以将其加入/etc/rc.dummynet
.分页: [1] [2]
- 上一篇:portsdb更新失败的解决办法
- 下一篇:OpenSSL应用简介