Use ipp2p + iptables to limit p2p protocol traffic

Source: Internet
Author: User
Use ipp2p + iptables to implement p2p protocol throttling-Linux Enterprise Application-Linux server application information. The following is a detailed description. Author: lishicun
1. Download the linux 2.4.31 kernel and unlock it.

2. Download The ebtables-brnf kernel patch from the http://ebtables.sourceforge.net, and use the diff command to patch the kernel

3. download the latest kernel version and Client Version of iptables.

4. Download, compile, and install the ipp2p package from www.ipp2p.org.

5. Compile the Linux kernel. Make sure to enable the iptables and QoS options. compile all related items into modules.

6. Write the following script

#! /Bin/sh

# The modules used here are: cls_fw sch_htb ipt_ipp2p ipt_MARK ipt_mark ipt_CONNMARK iptable_mangle iptable_filter ip_tables

Iptables-F-t mangle

Iptables-a prerouting-t mangle-p tcp-j CONNMARK -- restore-mark
Iptables-a prerouting-t mangle-p tcp-m mark! -- Mark 0-j ACCEPT
Iptables-a prerouting-t mangle-p tcp-m ipp2p -- ipp2p-j MARK -- set-mark 1
Iptables-a prerouting-t mangle-p tcp-m mark -- mark 1-j CONNMARK -- save-mark

Tc class del dev eth0 classid :12
Tc class del dev eth0 classid :10
Tc class del dev eth0 classid 1:1
Tc qdisc del dev eth0 root

Tc qdisc add dev eth0 root handle 1: htb default 12

Tc class add dev eth0 parent 1: classid htb rate 1000 mbit ceil 1000 mbit
Tc class add dev eth0 parent classid htb rate 100 kbit
# Ceil 100 kbps
# Tc class add dev eth0 parent classid htb rate 10 kbps ceil 100 kbps
Tc class add dev eth0 parent classid htb rate 1000 mbit ceil 1000 mbit

Tc qdisc add dev eth0 parent :10 handle 20: sfq perturb 10
# Pfifo limit 5
# Tc qdisc add dev eth0 parent :11 handle 30: pfifo limit 5
Tc qdisc add dev eth0 parent :12 handle 40: sfq perturb 10

Tc filter add dev eth0 parent 1:0 protocol ip prio 4 handle 1 fw classid :10
# Tc filter add dev eth1 parent 2: 0 protocol ip prio 4 handle 1 fw classid 2: 11

In this script, the tc class add dev eth0 parent classid htb rate 100 kbit statement is the most important. 100kbit indicates that the flow rate is limited to 100 kbit.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.