Set iptables firewall on CentOS6 system

Source: Internet
Author: User
To configure the firewall on Centos, you only need to write the configuration file to/etc/sysconfig/iptables without entering additional commands. Of course, the premise is that you have to install iptables. 1. install iptables. 2. set firewall filtering rules. # Under vi/etc/sysconfig/iptables, a ready-made iptables configuration file has been added to configure the firewall on Centos. you only need to write the configuration file to/etc/sysconfig/ Iptables. Of course, the premise is that you have to install Iptables.
1. install iptables.
2. set firewall filtering rules.
# Vi/etc/sysconfig/iptables
The following is a ready-made iptables configuration file that has added pptpvpn penetration. you can use pptpvpn normally.
* Filter
# Allow loopback (lo0) traffic and drop all traffic to/that doesn't use the lo0 interface
-A input-I lo-j ACCEPT
-A input-I! Lo-d 127.0.0.0/-j REJECT
# Accept established inbound connections
-A input-m state -- state ESTABLISHED, RELATED-j ACCEPT
# Allow all outbound traffic
-A output-j ACCEPT
# Allow HTTP and HTTPS connections
-A input-p tcp -- dport-j ACCEPT
-A input-p tcp -- dport-j ACCEPT
# Allow SSH/SFTP
# Change the value if you are using a non-standard port
-A input-p tcp-m state -- state NEW -- dport-j ACCEPT
# Allow FTP
# Purely optional, but required for WordPress to install its own plugins or update itself.
-A input-p tcp-m state -- state NEW -- dport-j ACCEPT
# Allow PING
# Again, optional. Some disallow this altogether.
-A input-p icmp-m icmp -- icmp-type-j ACCEPT
# Allow PPTP VPN
-A input-I eth0-p tcp -- dport-j ACCEPT
-A input-I eth0-p gre-j ACCEPT
-A forward-I ppp +-o eth0-j ACCEPT
-A forward-I eth0-o ppp +-j ACCEPT
# Reject ALL other inbound
-A input-j REJECT
-A forward-j REJECT
COMMIT
Check whether the filter rule is enabled:
This completes. After the VPS is restarted, the firewall rules are automatically enabled. Unlike debian, you must add startup commands to enable firewall rules.

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.