清风徐来
知是行之始,行是知之成

阿里云 ubuntu 的防火墙操作

Work ubuntu阿里云iptables 约 1 分钟
本文目录

与“阿里云 ubuntu 的防火墙操作”相关的原创示意图 阿里云服务器,没有 web 面板权限,只有 root 用户。

重新安装了服务器的 web 环境,需要开发相关端口。

检查防火墙 #

$whereis iptables iptables: /sbin/iptables /etc/iptables.rules /usr/share/iptables /usr/share/man/man8/iptables.8.gz 说明防火墙开了

根据上面的路径,编辑规则 #

$vi /etc/iptables.rules -A INPUT -p tcp -m state –state NEW -m tcp –dport 9443 -j ACCEPT -A INPUT -p udp -m state –state NEW -m udp –dport 9443 -j ACCEPT 以上放行了9443的 tcp 和 udp(拷贝已有规则改端口就好)

更新规则 #

$iptables-restore < /etc/iptables.rules $chmod +x /etc/network/if-pre-up.d/iptables

查看一下 #

$iptables -L -n Chain INPUT (policy DROP) target prot opt source destination
ACCEPT all – 0.0.0.0/0 0.0.0.0/0
ACCEPT all – 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22 ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:9443 ACCEPT udp – 0.0.0.0/0 0.0.0.0/0 state NEW udp dpt:9443 … 看到了我们放行的端口

end.