日志文章列表

2006年12月11日 23:03:12

现在的blog好漂亮啊

好久不看到,真的有了很大的变化
支持下

类别: 无分类 |  评论(1) |  浏览(5553) |  收藏
2006年12月05日 13:09:49

FreeBSD下ADSL共享上网

概述







利用FreeBSD用户级的PPP做FreeBSD下的ADSL共享上网,可以使用较低的设备配置,实现



局域网的稳定的网络链路共享。同时还可以增加Squid做上网的代理,进一步增加局域网



上网的速度。







FreeBSD可以对PPP提供两种不同方式的支持,一种是内核级PPP,它将PPP协议代码编译



进内核,并运行一个PPP守护进程pppd,提供对PPP的支持,这是比较传统的方法,但配



置比较困难。另一种为用户级PPP,使用一个应用程序PPP,通过通用tunnel设备传递PPP



数据,配置较为容易。一般情况下可以使用用户级的PPP来建立拨号方式的Internet连接。











准备







安装基本的FreeBSD环境,具体可以参照www.freebsdchina.org李冬的《FreeBSD服务器



指南》。必须安装操作系统源代码中的”sys”部分,下面需要重新编译内核以支持防火墙。







然后还需要确认在/etc/ppp目录中是否存在ppp.conf 或者ppp.conf.sample文件。







实例



Dell gx110 PIII 128M 10G 3com905B-tx 10/100Mbps自适应PCI网络适配器。











安装设置







在 FreeBSD 下上网必须要有 tun 这个伪设备,所以必须在内核中加入对 tun 的支持。



在 tun 后面的 1 指定同时可以使用的 tun 设备的个数。







要让整个局域网上的用户都可以访问 Internet 您的机器必须有两张网卡,一个连接



ADSL设备,一个连接局域网的HUB或者switch。另外必须重新编译一次内核。这些选项



主要是在内核中加入对IP转发的支持。客户机将IP数据包发到FreeBSD,然后FreeBSD



就将这些数据包转发到指定的地址。这就是让 FreeBSD 带动整个局域网上网的基本原理。







实例







在内核文件中添加如下内容:







device tun 1 # 根据实践发现此行内容可以不加。



options IPFIREWALL # 打开防火墙选项



options IPFIREWALL_FORWARD



options IPFIREWALL_VERBOSE # 向系统的注册程序发送注册信息包



options IPFIREWALL_VERBOSE_LIMIT=100 # 限制一台机器注册的次数



options IPFIREWALL_DEFAULT_TO_ACCEPT # 使得缺省的规则允许所有形式的访问



options IPDIVERT # 启用由ipfw divert使用的转向IP套接字



# 这一选项需要与natd联合使用







要启用ipfw,必须设置IPFIREWALL选项,它将通知操作系统的内核检查每个IP数据包,



将它们与规则集进行比较,通过添加IPFIREWALL_VERBOSE选项包括注册支持是一个好主



意,还应该通过添加IPFIREWALL_VERBOSE_LIMIT选项来限制内核注册的数据包的数量。











配置







还需要设置etc/ppp/ppp.conf文件







实例







/etc/ppp/ppp.conf







default:



set log Phase tun command #



set ifaddr 10.0.0.1/0 10.0.0.2/0 #设置本地PPP连接的IP地址







adsl : #配置代号



set device PPPoE: xl1 # 用你的网卡设备名称替代xl1



set authname #你的ADSL登陆名称



set authkey #你的账号密码



set dial



set login



add default HISADDR # 设置默认路由为对方的地址



enable dns #从拨号服务器中获得正确的DNS服务器地址







配置



最后,设置/etc/rc.conf文件打开gateway选项。



实例



编辑/etc/rc.conf 文件



加入:



gateway_enable="YES"



特别提示:如果要实际开机自动拨号,还要增加以下内容到 /etc/rc.conf 文件里!



ppp_enable="YES"



ppp_mode="ddial"



ppp_nat="YES"



ppp_profile="adsl" # 所要拨号的配置代号







配置



在如上述配置完毕,网络访问会有问题,因为防火墙的默认配置是都不可访问。下面需



要配置防火墙规则来允许访问,和禁止访问。







实例



首先用如下命令察看当前的防火墙配置:



/sbin/ipfw –a show



然后执行以下的命令进行防火墙的设置:



/sbin/ipfw add 00400 divert natd ip from any to any via xl0 //用于启动Natd 服务



/sbin/ipfw add 00001 deny log ip from any to any ipopt rr



/sbin/ipfw add 00002 deny log ip from any to any ipopt ts



/sbin/ipfw add 00003 deny log ip from any to any ipopt ssrr



/sbin/ipfw add 00004 deny log ip from any to any ipopt lsrr



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



/sbin/ipfw add 19997 check-state



/sbin/ipfw add 19998 allow tcp from any to any out keep-state setup



/sbin/ipfw add 19999 allow tcp from any to any out



/sbin/ipfw add 20001 allow udp from any 53 to me in recv xl0 //允许外网的DNS服务器的信息进入改服务器



/sbin/ipfw add 29999 allow udp from any to any out //允许自己的UDP包往外发,进行DNS信息查询



/sbin/ipfw add 30000 allow icmp from any to any icmptypes 3



/sbin/ipfw add 30001 allow icmp from any to any icmptypes 4



/sbin/ipfw add 30002 allow icmp from any to any icmptypes 8 out



/sbin/ipfw add 30003 allow icmp from any to any icmptypes 0 in



/sbin/ipfw add 30004 allow icmp from any to any icmptypes 11 in



/sbin/ipfw add 40000 allow all from 192.168.0.0/16 to any



/sbin/ipfw add 40001 allow all from any to 192.168.0.0/16



/sbin/ipfw flush //使防火墙规则生效







最后用/sbin/ipfw –a show 察看修改后的防火墙设置:



00001 0 0 deny log logamount 100 ip from any to any ipopt rr



00002 0 0 deny log logamount 100 ip from any to any ipopt ts



00003 0 0 deny log logamount 100 ip from any to any ipopt ssrr



00004 0 0 deny log logamount 100 ip from any to any ipopt lsrr



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



00100 516 68656 allow ip from any to any via lo0



00200 0 0 deny ip from any to 127.0.0.0/8



00300 0 0 deny ip from 127.0.0.0/8 to any



00400 0 0 divert 8668 ip from any to any via xl0



19997 0 0 check-state



19998 368990 279745596 allow tcp from any to any keep-state out setup



19999 872 154180 allow tcp from any to any out



20001 0 0 allow udp from any 53 to me in recv xl0



29999 3758 444913 allow udp from any to any out



30000 145 9690 allow icmp from any to any icmptype 3



30001 0 0 allow icmp from any to any icmptype 4



30002 0 0 allow icmp from any to any out icmptype 8



30003 0 0 allow icmp from any to any in icmptype 0



30004 0 0 allow icmp from any to any in icmptype 11



40000 7572 714836 allow ip from 192.168.0.0/16 to any



65535 3213 496794 allow ip from any to any







成功配置文档模板



rc.conf:



hostname="sample.com"



ifconfig_xl1="inet 192.168.9.6 netmask 255.255.255.0"



kern_securelevel_enable="NO"



nfs_reserved_port_only="NO"



firewall_enable="YES"



firewall_script="/etc/rc.firewall"



firewall_type="/etc/ipfw.conf"



firewall_quiet="YES"



firewall_logging_enable="YES"



sendmail_enable="NO"



sshd_enable="YES"



usbd_enable="NO"



gateway_enable="YES"



natd_interface="xl0"



natd_enable="YES"



natd_flags="-config /etc/natd.conf"



ppp_enable="YES"



ppp_mode="ddial"



ppp_nat="YES"



ppp_profile="adsl"







/etc/ppp/ppp.conf:



default:



set log Phase tun command



set ifaddr 10.0.0.1/0 10.0.0.2/0



adsl:



set device PPPoE:xl0



set mru 1492



set mtu 1492



set authname ad50103024



set authkey Sstc1602



set dial



set login



add default HISADDR











参考资料:



http://www.sms55.cn/reg.htmwww.freebsd.org/doc/en_US.ISO8859-1/books/handbook/pppoe.html

Tags: FreeBSD  

类别: 无分类 |  评论(0) |  浏览(7787) |  收藏
2006年12月05日 13:08:22

如何使用FreeBSD防火墙保护企业网络 

以前我已经写过一次《利用FreeBSD组建安全的网关》,主要偏向于如何建立一个FreeBSD防火墙,而防火墙在很多时候主要是要看如何使用,现在我们看看如何使用建立好了的FreeBSD防火墙保护企业,关于FreeBSD的防火墙建设过程请参考我的《利用FreeBSD组建安全的网关》,首先假设某企业有以下服务器和工作站:

1、WEB服务器两台、一台企业主页,一台做BBS,希望IP地址为xxx.xxx.xxx.001和xxx.xxx.xxx.002

2、DNS服务器一台,并且兼带企业E-mail服务,IP地址为xxx.xxx.xxx.003,把www.testdomain.com解析到xxx.xxx.xxx.001以及bbs.testdomain.com解析到xxx.xxx.xxx.002

3、企业内部局域网络,计算机N台,IP地址为10.125.0.0到10.125.255.255

对于这样的一个企业,我们首先要设计好网络构架,在设计的同时要考虑到各个服务器以及内部网络各放在什么位置,才能更有效的配合防火墙,使得防火墙对每个部分都能充分的保护。

我们首先来分析一下“黑客”入侵的手段和途径,作为一个入侵者,他的第一步自然是先要找到目标企业在网络中的位置,假设他已经知道该企业没有使用主机托管服务,而是和企业的网络放在了一起,那么他只须ping一下该企业的主页就能了解到该企业的IP地址为xxx.xxx.xxx.001和xxx.xxx.xxx.002,而另外还有一台DNS服务器,也可以使用nslookup这样的工具,一下就能查到目标企业的DNS服务器为地址xxx.xxx.xxx.003,并且他还会计划,假设已经进入以上三台服务器中的一台,他就会马上分析网络结构,并且进入内网,获取内部网络员工资料,以及很多重要数据。从上面看得出来,要保护这个网络,我们需要做很多东西,首先我们可以想办法对服务器之间以及服务器和内部网络之间进行隔离,但又能应用到他们应该有的功能,现在对该企业的网络做如下策划:



首先确定FreeBSD防火墙是作为企业连接到Internet服务器的唯一途径,然后对FreeBSD进行一定的设置,开启它的ipfirewall以及NATD功能,上图告诉了我们现在是把WWW、BBS、DNS等服务器都放在内部进行保护,所以在防火墙要开启NATD的反向代理功能,首先我们把xxx.xxx.xxx.001,xxx.xxx.xxx.002,xxx.xxx.xxx.003,绑定在FreeBSD外部网卡上,假设外部网卡号为fxp0,在rc.conf里我们需要设置如下:

ifconfig_fxp0="inet xxx.xxx.xxx.001 netmask 255.255.255.0"

ifconfig_fxp0_alias0="inet xxx.xxx.xxx.002 netmask 255.255.255.0"

ifconfig_fxp0_alias1="inet xxx.xxx.xxx.003 netmask 255.255.255.0"

绑好之后我们现在就开始分析了,首先我们来看看内部网络,内部要上Internet就必须要有一个网关,并且让他们正常的使用网络,假设FreeBSD内部网卡编号为fxp1,那么我们还要在rc.conf里加入:

ifconfig_fxp1="inet 10.125.0.1 netmask 255.255.0.0"

然后在防火墙规则里加上:

divert 8668 ip from any to any via fxp0

这条规则,允许NATD服务,仅允许NATD服务还不行,还要设置内部网络能连接到Internet,我们再加上:

allow ip from any to 10.125.0.0/16

allow ip from 10.125.0.0/16 to any

内部网络设置Gateway为10.125.0.1,这样企业的内部网络就能正常连接到Internet了。

然后我们来看看WWW服务器,这个服务器一般来说只要开放三个端口就够了,第一个端口自然是HTTP端口不用说了,第二个端口那就是ftp端口以及ftp数据端口,其中HTTP端口自然是让Internet上以及企业内部访问的端口,而FTP端口是用来更新主页或做别的事的,并且只须要企业内部人员访问就足够了,当然有必要的话还要开telnet或ssh端口,这是方便企业内部系统管理员远程管理的,这里我建议使用ssh,并且为了防止万一入侵者进来了,他可能要对其他机器进行攻击,我决定对WWW服务器进行单独分离,现在假设FreeBSD的内部网卡编号为fxp1,我们编辑rc.conf文件,加上:

ifconfig_fxp1_alias0 ="inet 10.80.0.1 netmask 255.255.255.0"

然后我们把WWW的服务器设置成10.80这个网段,网关为10.80.0.1,这样就把WWW服务器单独划在了一个特殊的区域里了,假设我们设置WWW的IP为10.80.0.80现在我们再设置防火墙规则:

allow tcp from any to xxx.xxx.xxx.001 80 in

allow tcp from xxx.xxx.xxx.001 80 to any out //允许任意地方能访问防火墙的80

allow tcp from 10.80.0.80 80 to any out

allow tcp from any to 10.80.0.80 80 in //允许任意地方访问WWW服务器的80端口

allow tcp from 10.125.0.0/16 to 10.80.0.80 21 in

allow tcp from 10.125.0.0/16 to 10.80.0.80 20 in

allow tcp from 10.80.0.80 21 to 10.125.0.0/16 out

allow tcp from 10.80.0.80 20 to 10.125.0.0/16 out //允许内部网络使用FTP服务器连接WWW服务器

设置完成防火墙规则还不行还需要设置NATD,我们设置NATD为:

redirect_port tcp 10.80.0.80:80 xxx.xxx.xxx.001:80

这样设置以后,WWW服务器就可以允许企业内部人员顺利的更新主页和浏览主页了,而Internet却只能浏览WWW服务器上的主页,就算万一WWW服务器利用HTTP服务器入侵了该机器,由于该服务器的各种连接都被放火墙阻断,而无法对企业内部网络进行入侵和破坏,达到充分保护WWW服务器以及内部网络的目的。

现在我们再来分析DNS服务器,由于BBS服务器和WWW服务器实质上都一样这里就不讨论了,DNS服务器自然要提供DNS服务器,也就是UDP53端口,由于同时还带MAIL功能,所以还要开放SMTP端口以及POP3端口,而POP3服务器同样只允许内部企业访问,所以我们给rc.conf加入:

ifconfig_fxp1_alias0="inet 10.80.2.1 netmask 255.255.255.0"

然后给DNS服务器设置IP为10.80.2.53,设置防火墙规则为:

allow udp from any to xxx.xxx.xxx.003 53 in

allow udp from xxx.xxx.xxx.003 53 to any out //允许任意地方能访问防火墙的53端口

allow tcp from any to xxx.xxx.xxx.003 25 in

allow tcp from xxx.xxx.xxx.003 25 to any out //允许任意地方能访问防火墙的smtp端口

allow udp from 10.80.2.53 53 to any out

allow udp from any to 10.80.2.53 53 in //允许任意地方访问DNS服务器的53端口

allow tcp from any to 10.80.2.53 25 in

allow tcp from 10.80.2.53 25 to any out //允许任意地方访问DNS的SMTP端口

allow tcp from 10.125.0.0/16 to 10.80.2.53 110 in

allow tcp from 10.80.2.53 110 to 10.125.0.0/16 out //允许企业内部访问DNS的POP3端口

NATD设置为:

redirect_port udp 10.80.2.53:53 xxx.xxx.xxx.003:53 //把10.80.2.53的53转到xxx.xxx.xxx.003的53上,使用的UDP。

redirect_port tcp 10.80.2.53:25 xxx.xxx.xxx.003:25 //把10.80.2.53的25转到xxx.xxx.xxx.003的25上,使用的TCP。

按照上面的规则设置好企业网络后,使得企业网络保护更加的严密,服务器和服务器之间以及服务器和企业内部网络之间进行了严格控制。当然这里没有考虑内部入侵,以及内部IP盗用行为,这也就是FreeBSD防火墙的局限性。不过可以添加一块网卡,把企业内部人员的网络单独用一个网卡来进行隔离,达到弥补的办法。

好了,以上为我使用FreeBSD防火墙保护企业网络的个人做法,希望能给一部分企业网管有所帮助。
_________________

Tags: FreeBSD  

类别: 无分类 |  评论(0) |  浏览(7751) |  收藏
2006年12月05日 13:06:02

收集的比较全网通的ip

有很多ip段我已经合在一起了的,教育网访问网通的速度比较好,几个油田基本使用的也是网通的带宽,所有我也加入了,希望大家能共同把它完善。

Quote:
//cncip
58.16.0.0/16
58.17.0.0/17
58.17.128.0/17
58.18.0.0/16
58.19.0.0/16
58.20.0.0/16
58.21.0.0/16
58.22.0.0/15
58.240.0.0/15
58.242.0.0/15
58.244.0.0/15
58.246.0.0/15
58.248.0.0/13
59.80.0.0/14
60.0.0.0/13
60.8.0.0/15
60.10.0.0/16
60.11.0.0/16
60.12.0.0/16
60.13.0.0/18
60.13.128.0/17
60.14.0.0/15
60.16.0.0/12
60.24.0.0/14
60.28.0.0/15
60.30.0.0/16
60.31.0.0/16
60.55.0.0/16
60.208.0.0/13
60.216.0.0/15
60.218.0.0/15
60.220.0.0/14
61.4.64.0/20
61.48.0.0/14
61.52.0.0/15
61.54.0.0/16
61.55.0.0/16
61.128.210.0/24
61.129.58.0/24
61.133.0.0/17
61.134.96.0/19
61.134.128.0/17
61.134.192.0/18
61.135.0.0/16
61.136.0.0/16
61.136.64.0/18
61.137.128.0/17
61.138.0.0/18
61.138.64.0/18
61.138.128.0/18
61.139.128.0/18
61.148.0.0/15
61.156.0.0/16
61.158.0.0/17
61.158.128.0/17
61.159.0.0/18
61.161.0.0/18
61.161.128.0/17
61.162.0.0/16
61.163.0.0/16
61.167.0.0/16
61.168.0.0/16
61.176.0.0/16
61.179.0.0/16
61.180.128.0/17
61.181.0.0/16
61.182.0.0/16
61.189.0.0/17
61.237.148.0/24
124.64.0.0/15
124.88.0.0/16
124.89.0.0/17
124.89.128.0/17
124.90.0.0/15
124.92.0.0/14
124.128.0.0/13
124.160.0.0/16
125.32.0.0/16
125.33.0.0/16
125.34.0.0/16
125.35.0.0/17
125.35.128.0/17
125.36.0.0/14
125.40.0.0/13
125.58.128.0/17
162.105.0.0/16
166.111.0.0/16
202.38.143.0/24
202.91.0.0/22
202.96.0.0/18
202.96.64.0/21
202.96.72.0/21
202.96.80.0/20
202.97.128.0/17
202.97.192.0/19
202.97.224.0/21
202.97.232.0/21
202.97.240.0/20
202.98.0.0/19
202.98.8.0/21
202.98.16.0/20
202.99.0.0/16
202.102.128.0/18
202.102.136.0/21
202.102.144.0/20
202.102.160.0/19
202.102.224.0/19
202.102.232.0/21
202.102.240.0/20
202.106.0.0/16
202.107.0.0/17
202.108.0.0/16
202.110.0.0/17
202.110.192.0/18
202.111.128.0/18
202.127.194.0/23
202.127.212.0/22
203.93.0.0/16
203.175.192.0/18
210.12.0.0/15
210.14.160.0/19
210.14.192.0/18
210.15.0.0/17
210.15.128.0/18
210.21.0.0/16
210.22.0.0/16
210.45.128.0/20
210.51.0.0/16
210.52.0.0/15
210.72.96.0/20
210.73.32.0/19
210.74.96.0/19
210.74.128.0/19
210.82.0.0/15
211.95.192.0/18
211.97.245.0/24
211.151.0.0/16
211.158.0.0/16
211.163.0.0/16
218.4.0.0/14
218.8.0.0/15
218.10.0.0/16
218.11.0.0/16
218.12.0.0/16
218.21.128.0/17
218.24.0.0/15
218.26.0.0/16
218.27.0.0/16
218.28.0.0/15
218.56.0.0/14
218.60.0.0/15
218.62.0.0/17
218.67.128.0/17
218.68.0.0/15
218.104.0.0/16
218.105.0.0/16
218.106.0.0/15
218.108.0.0/15
218.247.32.0/19
219.154.0.0/15
219.156.0.0/15
219.158.0.0/16
219.159.0.0/18
220.248.0.0/14
220.252.0.0/16
221.0.0.0/12
221.136.0.0/16
221.192.0.0/14
221.196.0.0/15
221.198.0.0/16
221.199.0.0/19
221.199.32.0/20
221.199.64.0/18
221.199.128.0/18
221.199.192.0/20
221.200.0.0/14
221.204.0.0/15
221.206.0.0/16
221.207.0.0/18
221.207.64.0/18
221.207.128.0/17
221.208.0.0/12
222.128.0.0/12
222.160.0.0/15
222.162.0.0/16
222.163.0.0/19
222.163.32.0/19
222.163.64.0/18
222.163.128.0/17

//教育网
202.112.0.0/15
202.114.0.0/16
202.115.0.0/16
202.116.0.0/16
202.117.0.0/16
202.118.0.0/16
202.119.0.0/16
202.120.0.0/15
202.192.0.0/15
202.194.0.0/15
202.196.0.0/15
202.198.0.0/15
202.200.0.0/15
202.202.0.0/15
202.204.0.0/14
202.38.192.0/18
202.38.64.0/19
202.38.96.0/19
202.4.128.0/19
202.8.128.0/19
210.25.0.0/16
210.26.0.0/15
210.28.0.0/15
210.30.0.0/16
210.31.0.0/16
210.32.0.0/14
210.36.0.0/14
210.40.0.0/15
210.42.0.0/15
210.44.0.0/15
210.46.0.0/15
210.78.0.0/19
211.64.0.0/15
211.66.0.0/16
211.67.0.0/16
211.68.0.0/16
211.69.0.0/16
211.70.0.0/16
211.71.0.0/16
211.80.0.0/16
211.81.0.0/16
211.82.0.0/16
211.83.0.0/16
211.84.0.0/15
211.86.0.0/15
211.144.0.0/12
218.30.0.0/16
218.192.0.0/16
218.193.0.0/16
218.194.0.0/16
218.195.0.0/16
218.196.0.0/14
219.216.0.0/15
219.218.0.0/15
219.220.0.0/16
219.221.0.0/16
219.222.0.0/15
219.224.0.0/15
219.226.0.0/16
219.242.0.0/15
219.244.0.0/14
//济南百灵宽带
211.99.96.0/19
218.98.0.0/17
218.98.128.0/18
218.98.192.0/19
//华北油田
202.180.128.0/19
202.8.128.0/19
//辽河油田
203.79.0.0/20
//大庆油田
203.90.192.0/19
//杭州广电
219.82.0.0/16
218.108.0.0/15


from:http://www.sms55.cn/reg.htmwww.5y6s.com/bbs/read-htm-tid-1771.html

Tags: 网通ip  

类别: 无分类 |  评论(2) |  浏览(5123) |  收藏
2006年10月20日 10:05:23

phpwind让我非常郁闷的3点

1、论坛uid和其他产品的不统一性
2、伪静态的地址太长了
3、关联产品的整合不是很好

感觉是浪费~~~

Tags: bbs   blog  

类别: 无分类 |  评论(2) |  浏览(17839) |  收藏
«12 3 4567» Pages: ( 3/8 total )