Configure an iptables firewall instance in CentOS6
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. To configure the firewall on Centos, you only need to write the configuration file to/etc/sysconfig/iptables without entering additional commands. 1. install iptables # yuminstalliptables2, set anti-DDoS to configure the firewall on Centos, as long as you write the configuration file to/etc/sysconfig/ Iptables.
To configure the firewall on Centos, you only need to write the configuration file to/etc/sysconfig/iptables without entering additional commands.
1. install iptables
# Yum install iptables
2. set firewall filter 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 127/8 thatdoesn't use the lo0 interface
-A input-I lo-j ACCEPT
-A input-I! Lo-d 127.0.0.0/8-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 80-j ACCEPT
-A input-p tcp -- dport 443-j ACCEPT
# Allow SSH/SFTP
# Change the value 22 if you are using a non-standard port
-A input-p tcp-m state -- state NEW -- dport 22-j ACCEPT
# Allow FTP
# Purely optional, but required for WordPress to install its ownplugins or update itself.
-A input-p tcp-m state -- state NEW -- dport 21-j ACCEPT
# Allow PING
# Again, optional. Some disallow this altogether.
-A input-p icmp-m icmp -- icmp-type 8-j ACCEPT
# Allow PPTP VPN
-A input-I eth0-p tcp -- dport 1723-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:
# Iptables-L
After the firewall is restarted, the firewall rules are automatically enabled.
Note: In CentosNot like debian, you must add a startup command to enable firewall rules.
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