Iptables Settings for CENTOS6 servers (host firewall)

Source: Internet
Author: User

Iptables Settings for CENTOS6 servers (host firewall)


Vim/etc/sysconfig/iptables-config

Add to:

iptables_modules= "Ip_nat_ftp ip_conntrack_ftp" in order to enable the IPTABLES support FTP service module



Reboot will fail then set boot boot:


1 Script content:


vim/etc/sysconfig/iptables.sh


#!/bin/bash


Iptables-a clean_in-p TCP! --syn-m State--state New-j DROP

Iptables-a input-p TCP--tcp-flags all none-j DROP

Iptables-a input-p TCP--tcp-flags all all-j DROP

Iptables-a input-d 192.168.1.255-p icmp-j DROP

Iptables-a input-d 255.255.255.255-p icmp-j DROP

Iptables-a input-d 192.168.1.202-m State--state invalid-j DROP

Iptables-a input-d 192.168.1.202-p tcp-m multiport--dport 21,22,80-m State--state new-j ACCEPT

Iptables-a input-d 192.168.1.202-p tcp-m State--state related,established-j ACCEPT

Iptables-a input-d 192.168.1.202-p udp-m State--state related,established-j ACCEPT

Iptables-a input-d 192.168.1.202-p ICMP--icmp-type 8-m limit--limit 2/second--limit-burst 5-m State--state NEW,ES Tablished-j ACCEPT

Iptables-a output-s 192.168.1.202-m State--state established-j ACCEPT

Iptables-save >/etc/sysconfig/iptables-v1

echo "" >/etc/sysconfig/iptables

Sed-i "/^$/D"/etc/sysconfig/iptables

Service Iptables Restart

Iptables-f

Iptables-restore </ETC/SYSCONFIG/IPTABLES-V1


2 Give it permission to execute

chmod 755/etc/sysconfig/iptables.sh


3 Use a scheduled task (security) when testing

Yum-y Install at

Service ATD Restart

/etc/sysconfig/iptables.sh && at now + minutes

At> Service iptables Restart


4 test the script and put it in/etc/rc.d/rc.local every time the boot executes.

Vim/etc/rc.d/rc.local

Add to

/etc/sysconfig/iptables.sh


5 restart

----------------------------------------------------------------------



Iptables Settings for CENTOS6 servers (host firewall)

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.