Rhel5 l7 Kernel Compilation

Source: Internet
Author: User
1. recompile the linuxn kernel (1) unzip netfilter-layer7 and linxu kernel tar-jxfnetfilter-lay [table]-C/usr/srctar-jxflinux-2 [table]-C/usr/srccd/usr/src/linux-2 [table] patch-p1 & lt; /home/yangbo

I. recompile the linuxn kernel
(1) unzip the netfilter-layer7 and linxu kernel
Tar-jxf netfilter-lay [table]-C/usr/src
Tar-jxf linux-2 [table]-C/usr/src
CDS/usr/src/linux-2 [table]
Patch-p1(2) reconfigure kernel parameters
Cp/boot/config-[table]./config
Make menuconfig
Code Netfiler configuartion
Select "Network ---> Network Options --> Network Packet filering framework (Netfiler) --> Code Netfilter Configuration"
Compile the "Netfilter connection tracking support" function into "M]
Find "layer7" match support
"String" match support
"Time" match support
"Iprange" addres range match support
"Connlimit" match support
"State" match support
IP: Netfilter configuartion
Expand "Networking --> Network Options ---> Network Packet filering framework (Netfiler) --> IP: Netfilter configuartion" in sequence"
"IPv4 connection tracking support (require for NAT )"
"FUll NAT"
"MASQUERADE target support"
"REDIRECT ttarget support"
Compile all to [M]
File systems --> Ext3 journalling file system support remove [M]
(3) compile the kernel, install the kernel file, and copy the module file.
Make
Make modules_install
Make install
Bytes ----------------------------------------------------------------------------------------
(4) adjust the GRUB boot menu to enable the system to start the system with the new kernel by default.
Vi/boot/grub. conf
Default = 1
Change
Default = 0
Bytes ----------------------------------------------------------------------------------------


II. recompile and install iptables and install the L7-protocol protocol package
(1) uninstall the original iptables software package.
Rpm-e iptabnles-ipv6 iptanbles iptstate -- nodeps
(2) decompress and release the iptables source code package and apply the patch file.
Tar jxvf Co., iptables-1.4. [tables]-c/usr/src/
Cd/usr/src/iptables-1.4.2/
Cp/usr/src/netfilter-layer-v.2.21/iptables-1.4.1.1-for-kernel [tables]/libxt_layer7. * extensions/
(3) configure, compile and install iptables, and use the "-- with-ksource" parameter to specify the kernel source code path.
./Configure -- prefix =/-- with-ksource =/usr/src/linux-2.6.28.8
Make
Make install
(4) install the L7-protocol Protocol definition package
Tar zxvf L7-protocol [tables]
Cd L7-protocol [tables]
Make install


3. use iptables to set application-layer filter rules
Example 1: Use layer7 to display the matching policy and access data packets from the application layer, such as qq, msn, and edonkey.
Iptables-a forward-m layer7 -- l7proto qq-j DROP
Iptables-a forward-m layer7 -- l7proto msn-filetrandfer-j DROP
Iptables-a forward-m layer7 -- l7proto msnessenger-j DROP
Example 2: Use "connlimit" to display matching to control concurrent data connections. if more than 100 concurrent connections are allowed, the connection is rejected.
Iptables-a forward-p tcp -- syn-m connlimit -- connlimit-above 100-j DROP
Example 3: Use "-- time" to display and match the data access policy set according to the time range, and allow data access between-from Monday to Friday
Iptables-a forward-p tcp -- dport 80-m time -- timestart 8:00 -- timetop 18:00 -- weekdays Mon, Tue, wed, thu, fri-j ACC
Example 4: Use "string" to display network access data of matching policies including "tencent", "verycd", "porn", and "adult movies"
Iptables-a forward-p udp -- dport 53-m string -- string "tencent" -- algo bm-j DROP
Iptables-a forward-p udp -- dport 53-m string -- string "verycd" -- algo bm-j DROP
Iptables-a forward-p tcp -- dport 80-m string -- string "porn" -- algo bm-j DROP
Iptables-a forward-p tcp -- dport 80-m string -- string "adult movie" -- algo bm-j DROP

Author: Jia Xiaoyang"

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.