Configuration of Centos7 Firewall

Source: Internet
Author: User

Cd/usr/lib/firewalld/services directory to store the defined Network service and port parameters, system parameters, can not be modified.

cd/etc/firewalld/services/



Systemctl Status Firewall View Firewall service status

Firewall-cmd--state View the status of firewall

Firewall-cmd--list-all View Firewall rules


Method 1, modify the configuration file/etc/firewalld/zones/public.xml

[Root@nginx01 zones]# Cat Public.xml

<?xml version= "1.0" encoding= "Utf-8"?>

<zone>

<short>Public</short>

<description>for use with public areas. You don't trust the "other computers" networks to not harm your computer. Only selected incoming connections are accepted.</description>

<rule family= "IPv4" >

<source address= "122.10.70.234"/>

<port protocol= "UDP" port= "514"/>

<accept/>

</rule>

<rule family= "IPv4" >

<source address= "123.60.255.14"/>

<port protocol= "tcp" port= "10050-10051"/>

<accept/>

</rule>

<rule family= "IPv4" >

<source address= "192.249.87.114"/> The specified IP, specify the port, protocol

<port protocol= "tcp" port= "/>"

<accept/>

</rule>

<rule family= "IPv4" > Port 9527 ports for any IP access server

<port protocol= "tcp" port= "9527"/>

<accept/>

</rule>

</zone>

Add the required rules, put the source IP to 192.249.87.114, Port 80, protocol TCP

Need to back up the firewall before


Restart the Firewalld.service service

Service Firewalld Restart


Method 2,

Firwall-cmd--permanent--add-port=9527/tcp Inserts the firewall rule, puts through 9527 port.

This rule is generated automatically in/etc/firewall/zones/public.xml.

<service name= "Dhcpv6-client"/>

<port protocol= "tcp" port= "9527"/>

</zone>


Firewall-cmd--permanent--query-port=9527/tcp Query If the rule you just inserted takes effect

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.