CentOS 7 Open Firewall Port command

Source: Internet
Author: User
Tags iptables

CentOS 7 Open firewall Port command

Recently, the company's new server requirements with CentOS7, found that the previous CentOS 6 series of iptables related commands can not be used, check the next, found that CentOS 7 use FIREWALLD instead of the original iptables.

use the following methods:

>>> Shutdown Firewall

Systemctl Stop Firewalld.service #停止firewall
Systemctl Disable Firewalld.service #禁止firewall开机启动

>>> Open port
Firewall-cmd--zone=public--add-port=80/tcp--permanent
command meaning:
--zone #作用域
--ADD-PORT=80/TCP #添加端口, Format: Port/Communication protocol
--permanent #永久生效, failure after reboot without this parameter
>>> Reboot Firewall
Firewall-cmd--reload

Introduction to common commands
Firewall-cmd--state # #查看防火墙状态, is running
Firewall-cmd--reload # #重新载入配置, such as adding a rule, you need to execute this command
Firewall-cmd--get-zones # #列出支持的zone
Firewall-cmd--get-services # #列出支持的服务, the services in the list are released
Firewall-cmd--query-service FTP # #查看ftp服务是否支持, return yes or no
Firewall-cmd--add-service=ftp # #临时开放ftp服务
Firewall-cmd--add-service=ftp--permanent # #永久开放ftp服务
Firewall-cmd--remove-service=ftp--permanent # #永久移除ftp服务
Firewall-cmd--add-port=80/tcp--permanent # #永久添加80端口
Iptables-l-N # #查看规则, this command is the same as Iptables
Man Firewall-cmd # #查看帮助

more commands, using firewall-cmd--help to view Help files

>>> CentOS 7.0 uses firewall as a firewall by default, and iptables must be reset
1, directly shut down the firewall
Systemctl Stop Firewalld.service #停止firewall
Systemctl Disable Firewalld.service #禁止firewall开机启动

2, set iptables service
yum-y install iptables-services
If you want to modify the firewall configuration, such as adding firewall ports 3306
vi/etc/ SYSCONFIG/IPTABLES&NBSP
Add Rule
-A input-m State--state new-m tcp-p TCP--dport 3306-j ACCEPT

Save Exit
Systemctl Restart Iptables.service #重启防火墙使配置生效
Systemctl enable Iptables.service #设置防火墙开机启动
Finally reboot the system so that the settings take effect.

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.