本例中假设你在防火墙上使用"ppp0"接口连接Internet。
将下面的行放进 /etc/ipf.conf 以允许IPFilter防火墙放行所有的6to4数据包( \ 表示因空间限制换行,实际是一行内容):
代码: 全选
# Handle traffic by different rulesets
block in quick on ppp0 all head 1
block out quick on ppp0 all head 2
### Incoming packets:
# allow some IPv4:
pass in log quick on ppp0 proto tcp from any to any \
port = www flags S keep state keep frags group 1
pass in quick on ppp0 proto tcp from any to any \
port = ssh keep state group 1
pass in quick on ppp0 proto tcp from any to any \
port = mail keep state group 1
pass in log quick on ppp0 proto tcp from any to any \
port = ftp keep state group 1
pass in log quick on ppp0 proto tcp from any to any \
port = ftp-data keep state group 1
pass in log quick on ppp0 proto icmp from any to any group 1
# allow all IPv6:
pass in quick on ppp0 proto ipv6 from any to any group 1
pass in log quick on ppp0 proto ipv6-route from any to any group 1
pass in log quick on ppp0 proto ipv6-frag from any to any group 1
pass in log quick on ppp0 proto ipv6-icmp from any to any group 1
pass in log quick on ppp0 proto ipv6-nonxt from any to any group 1
pass in log quick on ppp0 proto ipv6-opts from any to any group 1
# block rest:
blockin log quick on ppp0 all group 1
### Outgoing packets:
# allow usual stuff:
pass out quick on ppp0 proto tcp from any to any flags S \
keep state keep frags group 2
pass out quick on ppp0 proto udp from any to any \
keep state keep frags group 2
pass out quick on ppp0 proto icmp from any to any \
keep state group 2
# allow all IPv6:
pass out quick on ppp0 proto ipv6 from any to any group 2
pass out log quick on ppp0 proto ipv6-route from any to any group 2
pass out log quick on ppp0 proto ipv6-frag from any to any group 2
pass out log quick on ppp0 proto ipv6-icmp from any to any group 2
pass out log quick on ppp0 proto ipv6-nonxt from any to any group 2
pass out log quick on ppp0 proto ipv6-opts from any to any group 2
# block rest:
block out log quick on ppp0 all group 2
现在你网络上的所有主机全可以发送("out"规则)和接收("in"规则)v4-封装的IPv6数据, 你可以将任何一台设置为6to4网关. 当然你只想在一台主机上设置,并且在本地主机间使用原生的IPv6, 而且你可能想使用限制性规则强制执行这个策略, 请参看 ipf.conf(5) 了解IPFilter规则的更多信息.
你的防火墙放行封装的IPv6数据包后, 你可能想设置你的6to4网关来监视IPv6通讯, 甚至是限制它们. 要这样做, 你也需要设置在6to4网关上的IPFilter. 要实现一个简单的监视, 在/etc/rc.conf 里启用 "ipfilter=yes" ,并且将下列内容添加到 /etc/ipf6.conf:
代码: 全选
pass in log quick on stf0 from any to any
pass out log quick on stf0 from any to any
它将记录"stf0"隧道接口上的所有的进站和出站(IPv6)通讯。如果需要你可以同时添加过滤规则.
如果你更想知道流量统计而非网络通信的简要报告, 推荐你使用"net-snmp"软件包内MRTG代替分析IPFilter日志文件.