linux l7filter命令行,Linux下使用l7-filter过滤QQ、迅雷、电驴等
环境:
RHEL6.6-x86_64
iptables-1.4.21.tar.bz2
l7-protocols-2009-05-28.tar.gz
netfilter-layer7-v2.23.tar.gz
kernel-2.6.35.8-l7
想禁止员工上班期间玩扣扣,下载电影浪费宝贵的带宽吗?l7-filter是个不错的选择。。
1、给内核打补丁
# tar xf linux-2.6.35.8.tar.gz -C /usr/src
# tar xf netfilter-layer7-v2.23
# cd /usr/src
# ln -s linux-2.6.35.8 linux
# cd linux
# patch -p1 < /root/netfilter-layer7-v2.23/kernel-2.6.35-layer7-2.23.patch
# cp /boot/config-2.6.32-504.el6.x86_64 /usr/src/linux/.config
# make menuconfig
选择以下几项做成内核模块
Networking support ---> Networking options ---> Network packet filtering framework (Netfilter) ---> Core Netfilter Configuration ---> Netfilter connection tracking support
Networking support ---> Networking options ---> Network packet filtering framework (Netfilter) ---> Core Netfilter Configuration ---> "layer7" match support
Networking support ---> Networking options ---> Network packet filtering framework (Netfilter) ---> Core Netfilter Configuration ---> "iprange" address range match support
Networking support ---> Networking options ---> Network packet filtering framework (Netfilter)--->IP: Netfilter Configuration ---> IPv4 connection tracking support (required for NAT) Full NAT
# make
# make modules_install
# make install
内核编译完以后重启
# uname -a
Linux localhost.localdomain 2.6.35.8-l7 #1 SMP Mon Apr 13 13:44:31 CST 2015 x86_64 x86_64 x86_64 GNU/Linux
2、安装iptables
rpm -e iptables-ipv5 iptables --nodeps
# cp /etc/init.d/iptables /
# tar xf iptables-1.4.21.tar.bz2
# cp /root/netfilter-layer7-v2.23/iptables-1.4.3forward-for-kernel-2.6.20forward/libxt_layer7.* /root/iptables-1.4.21/extensions/
# cd iptables-1.4.21
# ./configure --prefix=/usr --with-ksource=/usr/src/linux
# make
# make install
# cp /iptables-config /etc/sysconfig/iptables-config
# cp /iptables /etc/init.d/iptables
/etc/init.d/iptables配置文件
.........红色部分为要修改的部分
if [ ! -x /usr/sbin/$IPTABLES ]; then
echo -n $"${IPTABLES}:/usr/sbin/$IPTABLES does not exist."; warning; echo
exit 5
fi
# service iptables start
3、安装协议特征包:
# tar xf l7-protocols-2009-05-28
# cd l7-protocols-2009-05-28
# make install
查看支持的部分协议:
# ls protocols/
100bao.pat doom3.pat jabber.pat radmin.pat teamfortress2.pat
aim.pat edonkey.pat kugoo.pat rdp.pat teamspeak.pat
aimwebcontent.pat fasttrack.pat live365.pat replaytv-ivs.pat telnet.pat
applejuice.pat finger.pat liveforspeed.pat rlogin.pat tesla.pat
..........................
.........................
dayofdefeat-source.pat ident.pat pop3.pat ssh.pat xboxlive.pat
dazhihui.pat imap.pat pplive.pat ssl.pat xunlei.pat
dhcp.pat imesh.pat qq.pat stun.pat yahoo.pat
directconnect.pat ipp.pat quake1.pat subspace.pat zmaap.pat
dns.pat irc.pat quake-halflife.pat subversion.pat
4、使用QQ测试
安装部分已经完成,接下来使用QQ做测试,是否能拒绝QQ登录
两台主机:
主机A两个网卡分别对应 192.168.1.123 192.168.8.131 两个IP ------->指定规则
主机B 192.168.8.128 -------> 登录QQ
主机B想要连接互联网需要通过主机A转发,主机B的网关为192.168.8.131指向主机A,制定定以下规则:
# iptables -t nat -A POSTROUTING -s 192.168.8.0/24 -j SNAT --to-source 192.168.1.123
# iptables -A FORWARD -s 192.168.8.0/24 -m layer7 --l7proto qq -j DROP
通过上面两条规则,192.168.8这个网段内的所有主机都无法登录QQ。
可以看到下图中规则已经被匹配到:
[root@localhost ~]# iptables -D FORWARD 1
删除规则后可正常登录
linux l7filter命令行,Linux下使用l7-filter过滤QQ、迅雷、电驴等相关推荐
- linux l7filter命令行,Ubuntu下l7-filter-userspace安装
Ubuntu版本为9.10 发现了这个网站里面提供了已经编译好的程序,直接下载 l7-filter-userspace libnetfilter-conntrack3 libnetfilter-que ...
- 树莓派linux界面命令行,Linux/Raspberry Pi下使用基于命令行的网页浏览器
本文将向你介绍如何在树莓派上安装3个不同的基于文本的网页浏览器.大多数的网页浏览器在小派上运行都有点吃力,要不就是会消耗大量资源,所以一个替代方案就是使用一个基于命令行的网页浏览器. 到目前为止基于文 ...
- linux l7filter命令行,iptables--L7-filter实现高级管理
l7-filter是一个定义在应用层上的来过滤数据包的.它可以按照不同的应用进行过滤,比如过滤聊天工具QQ.MSN.eDonkey等应用. 接下来讲述l7-filter的编译安装和使用: 1.准备工作 ...
- Linux shell 命令行环境下使用阿里云盘
阿里云盘在内测的时候我就在使用,整体体验相当的好,最起码不会限速,比起下载速度只有十几 KB 的某垃圾云盘要强太多了. 当然除了使用各系统的客户端进行下载之外,我还想要在命令行进行操作,主要原因也是我 ...
- linux ocr 命令行,Linux平台的OCR软件:gImageReader
简介:gImageReader是一个GUI软件,实现利用tesseract OCR引擎(Tesseract本身是命令行工具)从Linux中的图像和PDF文档中识别文本. 概述 Tesseract最初是 ...
- linux l7filter命令行,centos 6 上安装l7 filter尝试过滤xunlei
平台:Centos 6 x86_64,默认内核版本2.6.34 1,准备 yum update -y yum install -y ncurses-devel gcc make bc wget pat ...
- linux p4 命令行,linux下的p4用法
一:linux客户端(perforce客户端 本例在debian) 1.安装 get 2.把解压的p4程序放到/usr/bin/p4 //(只要放到PATH路径中就行)要保证系统程序能找到 3 ...
- linux p4 命令行,linux下使用P4(命令行)
环境变量: export P4PASSWD=abcdefg export P4CLIENT=dyoldfish.com //这个可以不设 export P4USER=dyoldfish expo ...
- linux命令行安装java_如何在Linux平台命令行环境下安装Java1.6
在Debian平台,请输入以下的命令 $ sudo vi /etc/apt/sources.list 在里面加入下面的一行 deb http://ftp.us.debian.org/debian/ s ...
最新文章
- 打造完全绿色的TOTAL COMMANDER
- VBS基础篇 - 内置函数
- boost::foreach模块右值 const_r的测试程序
- .Net 程序集 签名工具sn.exe 密钥对SNK文件 最基本的用法
- python语言中strike_Python学习笔记
- 历史上有关人工智能的七个片段
- mysql 格式化_mysql中格式化数字详解
- 在计算机软件中 CUI的中文意思是,长江大学 计算机基础11-12上A卷cui
- 换个红圈1微信头像恶搞一下好友
- python3pygame 游戏程序_python3 pygame实现接小球游戏
- 推荐几个很好的资源下载网站
- 计算机磁盘管理只有C盘怎么办,新电脑只有C盘怎么办?手把手教你给硬盘分区!...
- IEC 60601-1-2020 最新英文-医疗电气设备--第1部分 基本安全性及性能的一般要求
- Laya之微信小游戏入门
- const、*、的大乱斗
- Spring aop 循环依赖 Is there an unresolvable circular reference?
- 解决手机QQ邮箱提醒收不到消息
- 纯C语言实现贪吃蛇游戏(VC6.0)
- 想要认认真真的夯实基础知识了
- 2018年9月24日的中秋之约--期限是2020中秋