Oracle Cloud甲骨文VPS在创建vps后某些服务要对防火墙进行放行设置。
甲骨文后台配置
1)查看实例详情,点击【虚拟云网络】

2)然后点击子网中的数据!

3)再点安全列表中的数据。

4)入站规则,可见仅开放了22端口!ICMP 也是关闭的(禁ping)!

5)编辑第一条数据。将目的地端口范围里的数据清空!保存即可!!

6)或者更暴力一点开放所有协议!!!


SSH里配置
关闭防火墙
关闭iptabls 或者 firewalld !建议单独开放自己需要的端口。
# 停止firewall
systemctl stop firewalld.service
# 禁止firewall开机启动
systemctl disable firewalld.service
# 关闭iptables
service iptables stop
# 去掉iptables开机启动
chkconfig iptables off
单独开放端口
(不推荐直接关闭防火墙和开放所有端口)
放行8888端口命令:
iptables -I INPUT -p 协议 -m 协议 –dport 端口 -j ACCEPT
iptables -I INPUT -p tcp --dport 8888 -j ACCEPT
开放所有端口
或者开放所有端口!
sudo iptables -P INPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -P OUTPUT ACCEPT
sudo iptables -F
关闭Iptable规则
Oracle自带的Ubuntu镜像默认设置了Iptable规则,关闭它。
apt-get purge netfilter-persistent
开启为:
apt-get install netfilter-persistent
然后重启:
reboot
强制删除
rm -rf /etc/iptables && reboot
查看规则是否生效,命令:
iptables -L
备注:
关闭所有端口
关闭所有的 INPUT FORWARD OUTPUT 只对某些端口开放。
下面是命令实现:
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP
再用命令iptables -L -n
查看 是否设置好, 好看到全部DROP
了。
删除规则
首先我们要知道 这条规则的编号,每条规则都有一个编号。通过iptables -L -n --line-number
可以显示规则和相对应的编号。
num target prot opt source destination
1 DROP tcp – 0.0.0.0/0 0.0.0.0/0 tcp dpt:3306
2 DROP tcp – 0.0.0.0/0 0.0.0.0/0 tcp dpt:21
3 DROP tcp – 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
多了 num 这一列, 这样我们就可以看到刚才的规则对应的是编号2,那么我们就可以进行删除了。
iptables -D INPUT 2
删除INPUT链编号为2的规则。
再iptables -L -n
查看一下,发现规则已经被清除了。