current position:Home>CentOS permanent open port number

CentOS permanent open port number

2022-01-27 04:18:21 Buji_ island

This article personal blog address :CentOS7 Open port ( permanent ) (leafage.top)

Usually in linux After the service is installed and started on , The Internet is inaccessible by default , Because the firewall doesn't allow , So turn on the firewall , Let it have access to these port numbers ( With redis For example ).

Method 1 : Use firewall

1、 Run the command :

firewall-cmd --get-active-zones
 Copy code 

After running , You can see zone name , as follows :

2、 Execute the following command :

firewall-cmd --zone=public --add-port=6379/tcp --permanent
 Copy code 

3、 service iptables restart , Run the command :

firewall-cmd --reload
 Copy code 

4、 Check whether the port number is on , Run the command :

firewall-cmd --query-port=6379/tcp
 Copy code 

Method 2 : Use iptables

1、 First run the following command :

/sbin/iptables -I INPUT -p tcp --dport xxx -j ACCEPT
 Copy code 

2、 And then run :

/etc/rc.d/init.d/iptables save
 Copy code 

Or the following operation commands :

-A INPUT -m state –state NEW -m tcp -p tcp –dport xxx -j ACCEPT
 Copy code 

And then execute the command :

-A INPUT -j REJECT –reject-with icmp-host-prohibited
 Copy code 

notes :xxx —— Indicates the port number you want to open , Such as :6379

test : stay windows Press down win+R key , Input cmd, Run the command ( To be opened telnet), If it becomes empty, it means success :

telnet  192.168.xx.xx 6379
 Copy code 

notes : Turn on telnet The method is as follows :

  1. Go to the control panel , Choose the program ;

  1. Click on the program , Enter programs and functions ;

  1. Check telnet function , Click ok .

copyright notice
author[Buji_ island],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270418165785.html

Random recommended