Configuration of CentOS 7 firewall

Source: Internet
Author: User
Tags centos

1. View firewalls running status Systemctl status firewall

2. Open Firewall firewall systemctl start FIREWALLD

3. Configure the rules of the firewall, only to configure zone as public rules,

(1), add the accessible port, the permanent parameter means that the restart after the permanent effect, if not add this parameter, restart will not take effect

Firewall-cmd--zone=public--add-port=80/tcp--permanent

(2), set fixed IP, access to MySQL service

Firewall-cmd--permanent--add-rich-rule ' rule family=ipv4 source address=111.111.111.111 port port=3306 protocol=tcp AC Cept

(3), set up SSH service, the Aliyun server's centOS7 default on the SSH service, so all IP access, if you need to set fixed IP access,

You can add a rule based on the command above

Firewall-cmd--permanent--add-rich-rule ' rule family=ipv4 source address=111.111.111.111 Port port=3306 protocol=tcp Accept '--add-rich-rule ' rule family=ipv4 source address=111.111.111.111 port port=22 protocol=tcp Accept '

View in the/etc/firewalld/zone/public.xml file, <service name= "ssh"/> Need this comment out, rule the port configured below will not take effect, otherwise, all IP can be logged in via SSH.


<?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>

<service name= "Dhcpv6-client"/>

<!--<service name= "ssh"/>-->

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

<rule family= "IPv4" >

<source address= "111.111.111.111"/>

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

<accept/>

</rule>

<rule family= "IPv4" >

<source address= "111.111.111.112"/>

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

<accept/>

</rule>

<rule family= "IPv4" >

<source address= "111.111.111.111"/>

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

<accept/>

</rule>

<rule family= "IPv4" >

<source address= "111.111.111.111"/>

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

<accept/>

</rule>

</zone> (4) can also directly modify the above configuration file, complete the configuration, restart the firewall

Systemctl Restart Firewalld


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.