Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set the CentOS Firewall Open Port

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Today, I will talk to you about how to set up CentOS firewall open ports, which may not be well understood by many people. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.

When we use the CentOS system, the CentOS firewall sometimes needs to change the settings. CentOS Firewall is turned on by default. The method to set CentOS Firewall Open Port is as follows:

Open the configuration file for iptables:

Vi / etc/sysconfig/iptables

Note when modifying CentOS firewall: be sure to give yourself a good way back, leaving a management port for VNC and a management port for SSh

Here is an example of iptables:

# Firewall configuration written by system-config-securitylevel

# Manual customization of this file is not recommended.

* filter

: INPUT ACCEPT [0:0]

: FORWARD ACCEPT [0:0]

: OUTPUT ACCEPT [0:0]

: RH-Firewall-1-INPUT-[0:0]

-An INPUT-j RH-Firewall-1-INPUT

-A FORWARD-j RH-Firewall-1-INPUT

-A RH-Firewall-1-INPUT-I lo-j ACCEPT

-A RH-Firewall-1-INPUT-p icmp- icmp-type any-j ACCEPT

-A RH-Firewall-1-INPUT-p 50-j ACCEPT

-A RH-Firewall-1-INPUT-p 51-j ACCEPT

-A RH-Firewall-1-INPUT-m state-state ESTABLISHED,RELATED-j ACCEPT

-A RH-Firewall-1-INPUT-m state-state NEW-m tcp-p tcp-dport 53-j ACCEPT

-A RH-Firewall-1-INPUT-m state-state NEW-m udp-p udp-dport 53-j ACCEPT

-A RH-Firewall-1-INPUT-m state-state NEW-m tcp-p tcp-dport 22-j ACCEPT

-A RH-Firewall-1-INPUT-m state-state NEW-m tcp-p tcp-dport 25-j ACCEPT

-A RH-Firewall-1-INPUT-m state-state NEW-m tcp-p tcp-dport 80-j ACCEPT

-A RH-Firewall-1-INPUT-m state-state NEW-m tcp-p tcp-dport 443-j ACCEPT

-A RH-Firewall-1-INPUT-j REJECT-reject-with icmp-host-prohibited

COMMIT

To modify the CentOS firewall, it is important to note that you must modify this file according to your own server.

For example, if you do not want to open port 80 to provide web services, you should delete this line accordingly:

-A RH-Firewall-1-INPUT-m state-state NEW-m tcp-p tcp-dport 80-j ACCEPT

Restart iptables after all modifications:

Service iptables restart

You can verify that all the rules are in effect: iptables-L.

In this way, we have completed the setting modification of the CentOS firewall.

After reading the above, do you have any further understanding of how to set the CentOS firewall open port? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report