Install and configure iptables in centos7 and disable firewall

Source: Internet
Author: User
1. configure the firewall. enable port 80 and Port 3306 CentOS7.0 and use firewall as the firewall by default. here, change it to iptables firewall. 1. disable firewall: systemctlstopfirewalld. service # Stop firewallsystemctldisablefirewalld. service

1. configure the firewall and enable port 80 and Port 3306

CentOS 7.0 uses firewall as the firewall by default. here, it is changed to iptables firewall.

1. disable firewall:

Systemctl stop firewalld. service # stop firewall

 

Systemctl disable firewalld. service # disable firewall startup

 

2. install iptables firewall it Network, http://www.it.net.cn

Yum install iptables-services # installation

 

Vi/etc/sysconfig/iptables # Edit the firewall configuration file

 

# Firewall configuration written by system-config-firewall

 

# Manual mizmization of this file is not recommended. it, http://www.it.net.cn

* Filter

 

: Input accept [0: 0]

 

: Forward accept [0: 0]

 

: Output accept [0: 0] Linux learning, http: // linux.it.net.cn

-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 it, http://www.it.net.cn

-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 Linux, http: // linux.it.net.cn

COMMIT

 

: Wq! # Save and exit

 

Systemctl restart iptables. service # restart the firewall to make the configuration take effect.

Systemctl enable iptables. service # set firewall startup

 

2. disable selinux it network and http://www.it.net.cn

Vi/etc/selinux/config

 

# SELINUX = enforcing # Comment out

 

# SELINUXTYPE = targeted # Comment out

 

SELINUX = disabled # Add Linux learning, http: // linux.it.net.cn

: Wq! # Save and quit Linux learning, http: // linux.it.net.cn

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.