局域网限制:FreeBSD 利用IPFW实现限制局域网使用QQ

  、分析腾讯QQ服务器分布范围:

  QQ服务器分为 3类:

  1、UDP 8000端口类7个:速度最快服务器最多QQ上线会向这7个服务器发送UDP数据包选择回复速度最快个作为连接服务器

  这7个服务器名字均以sz-sz7开头域后缀是tencent.com域名和IP对应为

  sz 61.144.238.145

  sz2 61.144.238.146

  sz3 202.104.129.251

  sz4 202.104.129.254

  sz5 61.141.194.203

  sz6 202.104.129.252

  sz7 202.104.129.253

  其它: 61.144.238.156   2、TCP HTTP连接服务器2个使用HTTP 80端口连接这2个服务器名字均以tcpconn开头域后缀是tencent.com域名和IP对应为

  tcpconn 218.17.209.23

  tcpconn3 218.17.209.23

  tcpconn2 218.18.95.153

  tcpconn4 218.18.95.153

  虽然有4个名字但是只有2个服务器

  3、会员VIP登陆服务器使用HTTP 443安全连接

  服务器IP 218.17.209.42

  由于第2、3种我这儿无法选择进行登陆我只是通过反向查询得到了IP及端口至于第1种我经过了详细测试封锁了这7个UDP服务器QQ是不能登陆

   2、实现限制内网客户端上QQ(注意:我网络是用nat+ipfw做透明代理加防火墙实现共享上网)

  1.加入以下规则使内核支持ipfw防火墙功能,重新编辑内核文件.

  options IPFIREWALL //通知操作系统内核检查每个IP数据包将它们和规则集进行比较

  options IPFIREWALL_FORWARD

  options IPDIVERT //启用由ipfw divert使用转向IP套接字选项需要和natd联合使用

  options IPFIREWALL_VERBOSE //向系统注册发送注册信息包

  options IPFIREWALL_VERBOSE_LIM99v=100 //限制台机器注册次数

  options IPSTEALTH //启动支持秘密转发代码选项在使防火墙不被traceroute和类似工具发现时很有用

  options IPFIREWALL_DEFAULT_TO_ACCEPT

  options ACCEPT_FILTER_DATA

  options ACCEPT_FILTER_HTTP //接受过滤器中静态连接

  options ICMP_BANDLIM //ICMP_BANDLIM根据带宽限制产生icmp般情况下我们需要这个选项它有助于你系统免受D.O.S.攻击

  2、内核编辑好以后在/etc/rc.conf文件中加入以下内容好让系统重启后防火墙自动启动

  gateway_enable="YES" //启动网关

  ##########IP-firewall#################

  firewall_enable="YES" //激活firewall防火墙

  firewall_type="/etc/ipfw.conf" //firewall自定义脚本

  firewall_quiet="NO" //起用脚本时是否显示规则信息现在为“NO”假如你防火墙脚本已经定型那么就可以把这里设置成“YES”了

  firewall_logging_enable="YES" //启用firewalllog记录"

  ##########NATD#######################

  natd_erface="rl0" //NATD服务启用在哪块网卡

  natd_enable="YES" //激活NATD服务

  natd_flags="-config /etc/natd.conf" //NATD服务参数设置文件

  3.设置完成后我们再编辑/etc/syslog.conf文件,加入以下代码:

  !ipfw

  *.* /var/log/ipfw.log

  4.在/var/log/建立个ipfw.log文件内容为空就可以了,然后保存退出(这是个记录防火墙日志文件)

  5.在/etc下也建立个natd.conf文件内容也为空保存退出(这是个nat配置文件可以作些NAT设置)

  6.在/etc下新建ipfw.conf文件在文件里写入以下内容:

  add 00400 divert natd ip from any to any via rl0

  add 00001 deny log ip from any to any ipopt rr

  add 00002 deny log ip from any to any ipopt ts

  add 00003 deny log ip from any to any ipopt ssrr

  add 00004 deny log ip from any to any ipopt lsrr

  add 00005 deny tcp from any to any in tcpflags syn,fin

  #####TCP#####

  add 10000 deny tcp from any to any 4000

  add 10001 deny tcp from any to any 8000

  add 10002 deny udp from any to any 4000

  add 10003 deny udp from any to any 8000

  add 10004 deny all from any to 61.144.238.145

  add 10005 deny all from 61.144.238.145 to any

  add 10006 deny all from any to 61.144.238.146

  add 10007 deny all from 61.144.238.146 to any

  add 10008 deny all from any to 202.104.129.251

  add 10009 deny all from 202.104.129.251 to any

  add 10010 deny all from any to 202.104.129.254

  add 10011 deny all from 202.104.129.254 to any

  add 10012 deny all from any to 61.141.194.203

  add 10013 deny all from 61.141.194.203 to any

  add 10014 deny all from any to 202.104.129.252

  add 10015 deny all from 202.104.129.252 to any

  add 10016 deny all from any to 202.104.129.253

  add 10017 deny all from 202.104.129.253 to any



  add 10018 deny all from any to 218.18.95.153

  add 10019 deny all from 218.18.95.153 to any

  add 10020 deny all from any to 218.17.209.23

  add 10021 deny all from 218.17.209.23 to any

  add 10022 deny all from any to 61.144.238.156

  add 10023 deny all from 61.144.238.156 to any

  add 10024 deny all from any to 218.17.209.42

  add 10025 deny all from 218.17.209.42 to any

  #####ICMP#####

  add 30000 allow icmp from any to any icmptypes 3

  add 30001 allow icmp from any to any icmptypes 4

  add 30002 allow icmp from any to any icmptypes 8 out

  add 30003 allow icmp from any to any icmptypes 0 in

  add 30004 allow icmp from any to any icmptypes 11 in

  #####LAN#####

  add 40001 allow all from any to any



Tags:  如何限制局域网网速 局域网流量限制 局域网限制网速 局域网限制

延伸阅读

最新评论

发表评论