1, view open ports in the firewall
sudo iptables -L -n
There are two ways to open ports
The first: Editing iptables file eg: sudo vi / etc / sysconfig / iptables
Add the need to open ports eg:
-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT
COMMIT
: Wq (save)
Then restart the firewall My approach is
sudo systemctl stop firewalld.service-- turn off the firewall
sudo systemctl start firewalld.service-- open the firewall
The second method:
use
firewall-cmd --permanent --add-port=80/tcp
或添加某一范围
firewall-cmd --permanent --add-port=1000-2000/tcp
Then restart the firewall My approach is
sudo systemctl stop firewalld.service-- turn off the firewall
sudo systemctl start firewalld.service-- open the firewall