使用幫助使用幫助
Linux系統防火墻放行端口
如果您服務器內安裝了寶塔面板,請直接登陸寶塔面板,安全,里面添加放行端口。如果添加后不生效,把防火墻開關一下即可。本教程操作僅限純凈版系統使用。
一,通過SSH工具遠程進入服務器。
兩種方式(任意一種都可以),1,使用工具;2,手動對防火墻添加規則。
1,使用工具,執行命令:
- wget -O ports.sh http://down.wshost.cc/SH/ports.sh && bash ports.sh && rm -rf ports.sh && bash auto_disk.sh
輸入需要放行的端口,回車,然后輸入協議,如果是tcp協議直接回車即可完成放行,如果是端口范圍,可輸入范圍端口,使用英文冒號隔開。支持刪除已放行的端口。
2,手動對防火墻添加規則,命令如下:
centos6:
iptables -I INPUT -p 協議 -m 協議 --dport 端口 -j ACCEPT iptables-save > /etc/sysconfig/iptables service iptables restart
centos7(firewalld和iptables只能使用其中一個):
a、iptables
iptables -I INPUT -p 協議 -m 協議 --dport 端口 -j ACCEPT iptables-save > /etc/sysconfig/iptables systemctl restart iptables
b、firewall
firewall-cmd --zone=public --add-port=端口/協議 --permanent firewall-cmd --reload
ubuntu:
本系統我司默認未啟用防火墻,如果需要可使用上面腳本放行或者啟用系統ufw防火墻進行操作
ufw enable (啟動防火墻) ufw allow 端口/協議 ufw reload