shorewall防火墙、共享上网(屏蔽BT、电驴、QQ)、Ntop流量监控、PPTP VPN拔入
时间:2007-08-01
来源:互联网
新人请教,gentoo做软路由,服务器,能做到什么程度
想到可能有一些朋友需要这样的文章,因此转载。
这是我实践记录下来的,希望各位有用,谢谢。
实现目标:防火墙、共享上网(屏蔽BT、电驴、QQ)、流量监控、VPN拔入。
方案说明:为了考虑维护方便以及与WINDOWS的兼容性,我采用了自己最熟悉的Gentoo作为基础系统。由于IPtable配制相对复杂,我采用了基于IPtable基础开发Shorewall作为防火墙,共享上网 技术上不应该单独列出来。因为防火墙增加一条规则即可实现,流量分析,我采用了图形化比较丰富的NTOP,VPN为了兼容WINDOWS,或者说为了偷懒,我采用了PPTP。
硬件配制:PII233、256M、8G
相关URL:
http://www.shorewall.net/
http://www.webmin.com/
http://www.ntop.org/
http://pptpclient.sourceforge.net/
非常基础的东西这里将不在介绍,直入主题。
#emerge gentoo-sources
内核配制部份:
Networking ----> ----Networking support Networking options ---->[*] Network packet filtering (replaces ipchains) //注:选中并进入 --- Network packet filtering (replaces ipchains)[*] Network packet filtering debugging Core Netfilter Configuration ---> IP: Netfilter Configuration --->
仅管你喜欢碰盯子,但我还是要提醒您:其中 Core Netfilter Configuration和IP: Netfilter Configuration 里面的下面几项 必需选中。
--- Core Netfilter Configuration < >Netfilter netlink interface <*> Netfilter Xtables support (required for ip_tables)
你会找不到的。因此这是一个盯子。
--- IP: Netfilter Configuration <*> Connection tracking (required for masq/NAT)[*] IP tables support (required for filtering/masq/NAT)
Cryptographic options ---> Cryptographic API [*] HMAC support <M> Null algorithms <M> MD4 digest algorithm <M> MD5 digest algorithm --- SHA1 digest algorithm <M> SHA256 digest algorithm <M> SHA384 and SHA512 digest algorithms <M> Whirlpool digest algorithms <M> Tiger digest algorithms <M> DES and Triple DES EDE cipher algorithms <M> Blowfish cipher algorithm <M> Twofish cipher algorithm <M> Serpent cipher algorithm <M> AES cipher algorithms <M> AES cipher algorithms (i586) <M> CAST5 (CAST-128) cipher algorithm <M> CAST6 (CAST-256) cipher algorithm <M> TEA, XTEA and XETA cipher algorithms --- ARC4 cipher algorithm <M> Khazad cipher algorithm <M> Anubis cipher algorithm <M> Deflate compression algorithm <M> Michael MIC keyed digest algorithm <M> CRC32c CRC algorithm <M> Testing module
Device Drivers ---> Network device support ---> <*> PPP (point-to-point protocol) support[*] PPP multilink support (EXPERIMENTAL)[*] PPP filtering <*> PPP support for async serial ports <*> PPP support for sync tty ports <*> PPP Deflate compression <*> PPP BSD-Compress compression <*> PPP MPPE compression (encryption) (EXPERIMENTAL) <*> PPP over Ethernet (EXPERIMENTAL) < > SLIP (serial line) support
说明:我当前的内核是2.6.16-r12
#make #make install #make modules_install #emerge syslog-ng #rc-update add syslog-ng default #emerge shorewall
# emerge -pv ppp pptpd [ebuild N ] net-dialup/ppp-2.4.2-r15 -activefilter -atm -dhcp -ipv6 -mppe-mppc +pam -radius 0 kB [ebuild N ] net-dialup/pptpd-1.2.3-r1 +tcpd 0 kB
#USE="-gtk" emerge ppp pptpd #echo "net-analyzer/ntop ~x86" >>/etc/portage/package.keywords #emerge ntop #/usr/bin/ntop -P /var/ntop -u ntop -A #emerge webmin #/usr/libexec/webmin/changepass.pl /etc/webmin/ root passwd
http://ip:10000 (进入WebMin管理)
http://ip:3000 (进入ntop流量监控页面)
下面开始PPTP的配制。
#nano /etc/pptpd.conf
# (Recommended) localip 100.100.100.249 remoteip 100.100.100.210-240 # or #localip 192.168.0.234-238,192.168.0.245 #remoteip 192.168.1.234-238,192.168.1.245
#nano /etc/ppp/options.pptpd
# The name is pretty arbitrary, but it must match the entry in your chap-secrets name pptpd # These are really unsecure methods, so they're disabled refuse-pap refuse-chap refuse-mschap # This is the most secure handshake method require-mschap-v2 # We want to force 128 bit encryption for the session require-mppe-128 # Enable a lot of debugging to the syslog (comment it out once everything works) debug # Make a lock file while the connection is open lock # Disable compression (it's not available with your module) nobsdcomp # Don't log to your terminal window nologfd
#nano /etc/ppp/chap-secrets
# client server secret IP addresses th pptpd mypassword * office pptpd pass 218.22.2.0/19
VPN配制完成了
下面开始Shorewall防火墙的配制
#nano /etc/shorewall/zones
#ZONE TYPE OPTIONS IN OUT # OPTIONS OPTIONS fw firewall net ipv4 local ipv4 vpn ipv4 #LAST LINE - ADD YOUR ENTRIES ABOVE THIS ONE - DO NOT REMOVE
#nano /etc/shorewall/interfaces
#ZONE INTERFACE BROADCAST OPTIONS local eth0 100.100.100.255 net eth1 detect vpn ppp+ #LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE
#nano /etc/shorewall/policy
############################################################################### #SOURCE DEST POLICY LOG LIMIT:BURST # LEVEL fw net ACCEPT fw local ACCEPT fw vpn ACCEPT local fw ACCEPT local net ACCEPT local vpn ACCEPT vpn fw ACCEPT vpn net ACCEPT vpn local ACCEPT net all DROP all all REJECT #LAST LINE -- DO NOT REMOVE
#nano /etc/shorewall/rules
#SECTION ESTABLISHED #SECTION RELATED ACCEPT net fw tcp 22,443,1723,3000,10000 #LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE
#nano /etc/shorewall/masq
#INTERFACE SUBNET ADDRESS PROTO PORT(S) IPSEC eth1 eth0 #LAST LINE -- ADD YOUR ENTRIES ABOVE THIS LINE -- DO NOT REMOVE
说明:在参考我的规则时,请注意到:我eth1是代表外网的,eth0才是内网,所以请不要搞错。
我需要VPN,所以我还继续添加VPN规则
#nano /etc/shorewall/tunnels
#TYPE ZONE GATEWAY GATEWAY # ZONE pptpserver vpn 100.100.100.249 #LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE
好了,到这里防火墙配制完了,用以下这条命令检查一下配制是否正常。
# shorewall check
nano /etc/shorewall/shorewall.conf
STARTUP_ENABLED=Yes
# /etc/init.d/shorewall start # rc-update add shorewall default # /etc/init.d/pptpd start # rc-update add pptpd default
作者:TH
日期:2006/7/30
感谢您阅读本文章,写的不好,请谅解!
作者: linuxth 发布时间: 2007-08-01
#echo "net-misc/l7-protocols ~x86" >> /etc/portage/package.keywords #emerge l7-protocols
--- IP: Netfilter Configuration <*> Connection tracking (required for masq/NAT)[*] Connection tracking flow accounting .......................................... <*> Layer 7 match support (EXPERIMANTAL)
#echo "net-firewall/iptables extensions" >> /etc/portage/package.use #emerge iptables
安装L7-protocols后,如果没有重新编译iptables,会出现该库不能找到错误“lib/iptables/libipt_layer7.so”
#nano /etc/shorewall/rules
添加屏蔽规则,如下内容:
#SECTION RELATED ACCEPT net fw tcp 22,443,1723,3000,10000 BitTorrent/DROP local net Edonkey/DROP local net ICQ/DROP local net #LAST LINE -- ADD YOUR ENTRIES BEFORE THIS ONE -- DO NOT REMOVE
#shorewall check #shorewall restart
#iptables -t mangle -I POSTROUTING -m layer7 --l7proto qq -j DROP #iptables -t mangle -I POSTROUTING -m layer7 --l7proto bittorrent -j DROP #iptables -t mangle -I POSTROUTING -m layer7 --l7proto edonkey -j DROP
echo "/root/layer.sh" >> /etc/conf.d/local.start
关于NTOP的两个载图,希望让未使用过NTOP的朋友,对他有点认识
作者: linuxth 发布时间: 2007-08-01
不过你能不能介绍一下用shorewall和iptables比起来有什么好处吗,iptables确实挺复杂的……
另外请教楼主一个问题,这个问题我自己没想明白,如果我用这台路由机上网,那么这台路由机的上网应用受不受诸如流量监控,p2p限制等作用?
作者: abcbuzhiming 发布时间: 2007-08-01
作者: abcbuzhiming
不过你能不能介绍一下用shorewall和iptables比起来有什么好处吗,iptables确实挺复杂的……
|
[i] net-firewall/shorewall
Available versions: 3.0.8 3.2.9 (~)3.2.10 (~)3.4.3 (~)3.4.5 {doc}
Installed versions: 3.4.5(08时30分48秒 2007年07月20日)(-doc)
Homepage: http://www.shorewall.net/
Description: Shoreline Firewall is an iptables-based firewall for Linux.
作者: zhou3345 发布时间: 2007-08-01
作者: zhou3345
abcbuzhiming抛砖引玉,众兄弟获益匪浅:)
eix shorewall [i] net-firewall/shorewall Available versions: 3.0.8 3.2.9 (~)3.2.10 (~)3.4.3 (~)3.4.5 {doc} Installed versions: 3.4.5(08时30分48秒 2007年07月20日)(-doc) Homepage: http://www.shorewall.net/ Description: Shoreline Firewall is an iptables-based firewall for Linux. |
作者: abcbuzhiming 发布时间: 2007-08-01
我知道Shoreline Firewall是基于iptables开发的,不过我就是想知道这东西相对iptables来说有些什么特点,iptables自己也能配成防火墙,比较复杂就是了,如果Shoreline Firewall 能简化配置过程,并且能达到iptables的高度自定义特性,倒是的确是个很好的选择。 |
作者: zhou3345 发布时间: 2007-08-01
作者: abcbuzhiming
如果我用这台路由机上网,那么这台路由机的上网应用受不受诸如流量监控,p2p限制等作用?
|
shorewall与iptable怎么理解?
shorewall你可以简单的理解为C语言,Iptable是汇编语言。
作者: linuxth 发布时间: 2007-08-02
作者: blackwhite 发布时间: 2007-08-02
还有如果BT,和电驴启用了加密协议,应该没用
作者: showboy 发布时间: 2007-08-02
作者: axlrose 发布时间: 2007-08-02
假设对内网卡是eth0,对外是eth1,一般来讲对内网卡的IP就是绑定为网关地址了,但是这个对外网卡的IP要怎么设置,这才是遇到的,以前用软路由软件不用面对这个问题……
再就是我的网络是用pppoe拨号的adsl,这样的话需要装dhcp 客户端吗?如果装了话,又怎么禁止系统在启动的时候自动开启dhcp client程序为我没有IP的网卡分配地址,这个过程往往要一段时间,影响启动速度。
PS:关于这个NTOP,我突然发现你这图好像只显示流量,不显示速度,NTOP没有针对IP的即时速度显示功能吗?这软件显示的时候能不能动态刷新啊
作者: abcbuzhiming 发布时间: 2007-08-03
对eth1设定IP不会影响PPPOE本身的,所以不用操心dhcp。
关于NTOP,一定时间会自动刷新,显示最新数据。 你指的速度,我明其意。NTOP主要用途是作流量分析的。
作者: linuxth 发布时间: 2007-08-03
作者: linuxth
原来你是pppoe呀,防火墙设定时“要举一反三”了。
对eth1设定IP不会影响PPPOE本身的,所以不用操心dhcp。 关于NTOP,一定时间会自动刷新,显示最新数据。 你指的速度,我明其意。NTOP主要用途是作流量分析的。 |
我说的速度显示就是按IP(mac)显示这个人当前的上传下载速率KB/S,就是监视他的上网速度。另外,流量分析应该分上传和下载吧这个NTOP显示出来的流量数据怎么看不出来是上传的还是下载的,还有一个人的总流量和整个网络对外的总流量也看不见啊
作者: abcbuzhiming 发布时间: 2007-08-03
更多功能,请访问官方网站。
http://www.ntop.org/overview.html
另外,ipcop这家伙也还不错,需求是否对的上,可以分析一下。
http://www.ipcop.org/
作者: linuxth 发布时间: 2007-08-03
另外,l7-filter里面的讯雷的定义也没用了。
作者: Steve3d 发布时间: 2007-08-04
作者: Steve3d
这个方法不能禁任何verycd版本的emule,verycd版本的emule很难搞, 我试了很久也只能让他得不到high-id而已。而且新的emule 0.48里面好象有了一个模糊协议或者叫协议欺骗(具体什么名记不清了),l7-filter对它也不能保证100%有效。
另外,l7-filter里面的讯雷的定义也没用了。 |
作者: abcbuzhiming 发布时间: 2007-08-04
提示iproute2需要在kernel2.16以前的版本使用
作者: 716011 发布时间: 2007-08-04
作者: zhllg 发布时间: 2007-08-05
为什么不连IE也封了?
作者: 夕角 发布时间: 2007-08-05
作者: 716011
emerge Shorewall 失败
提示iproute2需要在kernel2.16以前的版本使用 |
ACCEPT_KEYWORDS="~x86"
作者: linuxth 发布时间: 2007-08-05
作者: linuxth
如果加了~x86 就将其删除,如果没加,就将其加上,因为iproute2 patch的原因。总之当前配置要与安装核心时保持一至,然后重新emerge iproute2
代码:
ACCEPT_KEYWORDS="~x86" |
作者: abcbuzhiming 发布时间: 2007-08-05
作者: linuxth
如果加了~x86 就将其删除,如果没加,就将其加上,因为iproute2 patch的原因。总之当前配置要与安装核心时保持一至,然后重新emerge iproute2
代码:
ACCEPT_KEYWORDS="~x86" |
作者: 716011 发布时间: 2007-08-10
作者: 716011 发布时间: 2007-08-10
作者: axlrose 发布时间: 2007-08-10
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28