###Centos 7tcp
firewall-cmd --list-ports
firewall-cmd --zone=public --add-port=80/tcp --permanent –zone #做用域 –add-port=80/tcp #添加端口,格式爲:端口/通信協議 –permanent #永久生效,沒有此參數重啓後失效
firewall-cmd --zone=public --remove-port=9005/tcp --permanent
firewall-cmd --reload #重啓firewall systemctl start firewalld.service #啓動 systemctl start firewalld.service #重啓 systemctl stop firewalld.service #中止firewall systemctl disable firewalld.service #禁止firewall開機啓動 firewall-cmd --state #查看默認防火牆狀態(關閉後顯示notrunning,開啓後顯示running)
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT /sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT /sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
etc/rc.d/init.d/iptables save
/etc/init.d/iptables status
開啓: chkconfig iptables on 關閉: chkconfig iptables off
開啓: service iptables start 關閉: service iptables stop