iptables -version
/etc/init.d/iptables status
chkconfig iptables on
chkconfig iptables off
service iptables stop
service iptables start
service iptables restart
iptables -I INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
iptables -I OUTPUT -o eth0 -p tcp --sport 80 -j ACCEPT
/etc/rc.d/init.d/iptables save
iptables -I INPUT -i eth0 -p tcp --dport 80 -j DROP
iptables -I OUTPUT -o eth0 -p tcp --sport 80 -j DROP
/etc/rc.d/init.d/iptables save
systemctl start firewalld.service
systemctl stop firewalld.service
systemctl restart firewalld.service
systemctl status firewalld.service
systemctl enable firewalld.service
systemctl disable firewalld.service
systemctl is-enabled firewalld.service;echo $?
systemctl list-unit-files | grep enabled
firewall-cmd --zone=public --list-ports
sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
sudo firewall-cmd --reload
若不使用“--permanent”, 則防火墻規(guī)則在重啟后會失效.
sudo firewall-cmd --zone=public --remove-port=80/tcp --permanent
sudo firewall-cmd --reload
若不使用“--permanent”, 則防火墻規(guī)則在重啟后會失效.
apt install ufw
ufw version
ufw enable
ufw disable
ufw default allow/deny
ufw status
sudo ufw allow [service]
sudo ufw deny [service]
例如: sudo ufw allow ssh表明: 允許所有的外部IP訪問本機的22/tcp(ssh)端口
sudo ufw allow 22
sudo ufw deny 22
ufw allow from 122.168.254.254 to any
ufw deny from 122.168.254.254 to any
ufw allow from 122.168.254.254 to any port 80
ufw deny from 122.168.254.254 to any port 80
sudo ufw status numbered
# 會顯示防火墻的已有規(guī)則并編號
Status: active
To Action From
-- ------ ----
[ 1] Nginx HTTP ALLOW IN Anywhere
[ 2] OpenSSH ALLOW IN Anywhere
[ 3] Nginx HTTP (v6) ALLOW IN Anywhere (v6)
[ 4] OpenSSH (v6) ALLOW IN Anywhere (v6)
sudo ufw delete 3
版權(quán)聲明:本文內(nèi)容由互聯(lián)網(wǎng)用戶自發(fā)貢獻,版權(quán)歸作者所有l(wèi)inux常用命令,本社區(qū)不擁有所有權(quán)l(xiāng)inux常用命令,也不承擔相關法律責任。如果您發(fā)現(xiàn)本社區(qū)中有涉嫌抄襲的內(nèi)容,歡迎發(fā)送郵件至:yqgroup@service.aliyun.com進行舉報,并提供相關證據(jù),一經(jīng)查實,本社區(qū)將立刻刪除涉嫌侵權(quán)內(nèi)容。
上一個教程:linux常用命令大全(精心整理
下一個教程:linux的常用命令(實時更新)