For details about deploying the iptables environment in centos7, centos7iptables

Source: Internet
Author: User

For details about deploying the iptables environment in centos7, centos7iptables
Deploy the iptables environment record in centos7 (disable the default firewalle)

The default firewall of CentOS7 is not iptables, but firewall.
Because iptables is used to the firewall, after the centos7 system is installed, the default firewall is disabled and iptables is installed to Set firewall rules.

The following describes how to disable firewall and install iptables in centos7, and how to enable port 80 and port 3306:
[Root @ localhost ~] # Cat/etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

1. Disable firewall:

1 2 [Root @ localhost ~] # Systemctl stop firewalld. service // stop firewall [root @ localhost ~] # Systemctl disable firewalld. service // disable firewall startup

2. Install iptables Firewall

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 19 20 21 22 [Root @ localhost ~] # Yum install iptables-services // install [root @ localhost ~] # Vim/etc/sysconfig/iptables // edit the Firewall configuration file # firewall configuration written by system-config-Firewall # Manual manumization of this file is not recommended. * filter: input accept [0: 0]: forward accept [0: 0]: output accept [0: 0]-a input-m state -- state ESTABLISHED, RELATED-j ACCEPT-a input-p icmp-j ACCEPT-a input-I lo-j ACCEPT-A INPUT-m state -- state NEW-m tcp-p tcp -- dport 22 -j ACCEPT -A input-m state -- state NEW-m tcp-p tcp -- dport 80-j ACCEPT-a input-m state -- state NEW-m tcp-p tcp -- dport 3306- j ACCEPT-a input-j REJECT -- reject-with icmp-host-prohibited-a forward-j REJECT -- reject-with icmp-host-prohibited COMMIT [root @ localhost ~] # Systemctl restart iptables. service // restart the firewall to make the configuration take effect [root @ localhost ~] # Systemctl enable iptables. service // set the firewall to start from startup [root @ localhost ~] # Iptables-L // view firewall rules. The default value is-t filter. For nat tables, iptables-t nat-L

Ii. Disable SELINUX

1 2 3 4 5 6 7 [Root @ localhost ~] # Vim/etc/selinux/config # SELINUX = enforcing // comment out # SELINUXTYPE = targeted // comment out SELINUX = disabled // Add [root @ localhost ~] # Setenforce 0 // make the configuration take effect immediately

Related Article

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.