我在 Raspberry Pi 3 上运行云服务,并且也想从外部访问它。不幸的是,我的 ISP 不允许我转发端口(这是另一个故事),因此我有时还需要通过IPv6
.为了限制访问,IPv4
我设置了以下规则
# /etc/iptables/rules.v4
# Generated by iptables-save v1.4.21 on Fri Mar 10 18:07:14 2017
*filter
:INPUT DROP [10:3211]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [163:16092]
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
COMMIT
# Completed on Fri Mar 10 18:07:14 2017
一切都按预期进行。但是,当我尝试对 执行相同的操作IPv6
(即使用ip6tables
代替iptables
并尝试应用相同的规则)时,我无法再访问它了IPv6
。设置规则是否ip6tables
不同?
谢谢你!
答案1
好吧,看来添加以下两条规则有帮助。
-A INPUT -p udp -m udp --dport 546 -m state --state NEW,ESTABLISHED -j ACCEPT
-A INPUT -p ipv6-icmp -j ACCEPT
这里是完整的rules.v6
# Generated by ip6tables-save v1.4.21 on Wed May 17 10:14:19 2017
*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [110:14552]
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -m state --state NEW,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
-A INPUT -p udp -m udp --dport 546 -m state --state NEW,ESTABLISHED -j ACCEPT
-A INPUT -p ipv6-icmp -j ACCEPT
COMMIT
# Completed on Wed May 17 10:14:19 2017