CentOS6.4 use iptables to protect system security

Source: Internet
Author: User
Edit/etc/rc. local and enter the following content :#! /Bin/sh # Thisscriptwillbeexecuted * after * alltheotherinitscripts. # Youcanputyourowninitializationstuffinhereifyoudont # wanttodothefullSysVst

Edit/etc/rc. local and enter the following content:
#! /Bin/sh
#
# This script will be executed * after * all the other init scripts.
# You can put your own initialization stuff in here if you don't
# Want to do the full Sys V style init stuff.
Touch/var/lock/subsys/local
# StartMemcached
/Usr/local/bin/memcached-d-m-u root-p-c-P/tmp/memcached. pid
# Configuring a firewall
/Sbin/Iptables-F
/Sbin/iptables-X
/Sbin/iptables-Z
/Sbin/modprobe ip_tables
/Sbin/modprobe iptable_nat
/Sbin/modprobe ip_nat_ftp
#/Sbin/modprobe ip_conntrack
/Sbin/iptables-P INPUT DROP
/Sbin/iptables-P FORWARD ACCEPT
/Sbin/iptables-P OUTPUT ACCEPT
# Up to 100 new connections are allowed per second
/Sbin/iptables-a input-f-m limit -- limit/sec -- limit-burst-j ACCEPT
# Prevent ping flood attacks. The maximum number of ping packets per second is 10.
/Sbin/iptables-a forward-p icmp -- icmp-type echo-request-m limit -- limit/s -- limit-burst-j ACCEPT
# Prevent various port scans and limit SYN and ack syn to no more than 200 per second, so as not to exhaust the bandwidth of the server
/Sbin/iptables-a input-p tcp-m tcp -- tcp-flags SYN, RST, ack syn-m limit -- limit/sec -- limit-burst-j ACCEPT
# Open access to a specified host, such as the IP address of the host for Intrusion Detection
#/Sbin/iptables-a input-s 122.70.x.x-j ACCEPT
# Loop data must be released
/Sbin/iptables-a input-I lo-j ACCEPT
/Sbin/iptables-a output-o lo-j ACCEPT
# Self-sent users can collect
/Sbin/iptables-a input-m state -- state ESTABLISHED, RELATED-j ACCEPT
# Open ports 80 and 22. do not explain/sbin/iptables-a input-p tcp-m multiport -- dport 80, 22-j ACCEPT

If the test fails to run automatically, you need to create a soft link:
Ln-s/etc/rc. local/etc/rc3.d/S99rc. local

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.