一、Ubuntu
Ufw enable
Ufw status
Ufw allow 22000
Ufw reload
二、Centos7
Systemctl start firewalld
Firewall-cmd –list-ports
Firewall-cmd –add-port=22000/tcp –permanent
Firewall-cmd reload
Systemctl enable firewalld
三、Centos6
iptables
开启防火墙(重启后永久生效):chkconfig iptables on
关闭防火墙(重启后永久生效):chkconfig iptables off
开启防火墙(即时生效,重启后失效):service iptables start
关闭防火墙(即时生效,重启后失效):service iptables stop
重启防火墙:service iptables restart
通过修改/etc/sysconfig/iptables文件的方式开启端口,如下
vi /etc/sysconfig/iptables
然后在文件中增加一行
-A INPUT -m state –state NEW -m tcp -p tcp –dport 22000 -j ACCEPT
重启防火墙:service iptables restart