Oracle Cloud 的ubuntu 镜像预置了iptables规则,即使你设置了安全组,子网,放通所有地址和端口,依然不能用。这里是一个粗暴的方法,删除了预置规则,关闭了Oracle 的初始化服务, 脚本内容:
#! /bin/bash
# Note: Run as root
# 清空 iptables
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -F
# 持久化 iptables,不需要删除 iptables包
netfilter-persistent save
# 停止 oracle 服务, 通过 systemctl --type=service 查看 cloud init 服务
systemctl disable cloud-config.service
systemctl disable cloud-final.service
systemctl disable cloud-init-local.service
systemctl disable cloud-init.service
# 重启 systemctl
systemctl daemon-reload
# 最后重启系统
shutdown -r