本文操作于ubuntu,其他系统类似
切换到root用户
sudo -i
开放所有端口
sudo iptables -P INPUT ACCEPT sudo iptables -P FORWARD ACCEPT sudo iptables -P OUTPUT ACCEPT sudo iptables -F
关闭Oracle自带Ubuntu镜像的Iptable规则
apt-get purge netfilter-persistent reboot
强制删除规则
rm -rf /etc/iptables && reboot
删除oracle-cloud-agent,防止甲骨文监控
snap remove oracle-cloud-agent
卸载重装防火墙
apt purge -y iptables-persistent iptables -L apt update -y && apt install -y iptables-persistent
编辑文件
nano /etc/iptables/rules.v4
编辑内容
*filter :INPUT DROP [0:0] :FORWARD DROP [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT -A INPUT -p tcp --dport 22 -j ACCEPT -A INPUT -i lo -j ACCEPT COMMIT
加载规则
iptables-restore < /etc/iptables/rules.v4 systemctl enable netfilter-persistent
查看链与规则
iptables -L
发布者:木木,转载请注明出处:https://blog.mmcool.site/4633.html