linux Open specified port command
Mode 1
CentOS:
1, Turn on Firewall
systemctl start firewalld
2, Open designated port
firewall-cmd --zone=public --add-port=6379/tcp --permanent
Command meaning :
–zone # Scope
–add-port=6379/tcp # Add port , Format is : port / Communication protocol
–permanent # Permanently effective , Failure after restart without this parameter
3, service iptables restart
firewall-cmd --reload
4, View port number
netstat -ntlp // View all current tcp port ·
netstat -ntulp |grep 6379 // View all 1935 Port usage ·

Mode II
# Open port :8080
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT

Mode III
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
service iptables restart

Technology