擦擦擦
我用的oracle compute instance ,系统是ubuntu 20.04
ssh 端口工作正常,连接没问题
所以用sudo python3 -m http.server 7500 建了个简单的服务
然后浏览器死活连不上。。。
vcn的subnet 的ingress rules已经打开了7500端口。。。
ubuntu的ufw也是 inactive。。。(oracle不建议用ufw)
搞了俩星期最后发现了原因。。。。
oracle oci的ubuntu镜像不是普通的ubuntu,特么有问题!!!
iptables有默认设置,需要修改才能打开端口。。。
sudo nano /etc/iptables/rules.v4
# CLOUD_IMG: This file was created/modified by the Cloud Image build process
# iptables configuration for Oracle Cloud Infrastructure
# See the Oracle-Provided Images section in the Oracle Cloud Infrastructure
# documentation for security impact of modifying or removing these rule
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [456:49023]
:InstanceServices - [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p udp --sport 123 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
#就是在这里添加下面这一句
-A INPUT -p tcp -m state --state NEW -m tcp --dport 7500 -j ACCEPT
#添加上面这句
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
然后重新加载一下
sudu su
iptables-restore < /etc/iptables/rules.v4
然后就可以了。。。
很奇怪,就算是卸载iptables都没用,只能改配置文件,或者临时用
sudo iptables -I INPUT -p tcp --dport 7500 -j ACCEPT
打开端口