在systemd-resolved之前,用于DNS的iptable规则是
DNS_SERVER="8.8.8.8 8.8.4.4"
echo "Set default INPUT policy to 'DROP'"
$IPT -P INPUT DROP
for ip in $DNS_SERVER
do
echo "Allowing DNS lookups (tcp, udp port 53) to server '$ip'"
$IPT -A OUTPUT -p udp -d $ip --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPT -A INPUT -p udp -s $ip --sport 53 -m state --state ESTABLISHED -j ACCEPT
$IPT -A OUTPUT -p tcp -d $ip --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPT -A INPUT -p tcp -s $ip --sport 53 -m state --state ESTABLISHED -j ACCEPT
done,它允许后续规则中的DNS解析,如这些规则可以到达github。
$IPT -A OUTPUT -p tcp -d "github.com" --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
$IPT -A INPUT -p tcp -s "github.com" --sport 443 -m state --state ESTABLISHED -j ACCEPT但是对于systemd-resolved,/etc/resolv.conf现在有了指向127.0.0.53的存根
而iptables脚本挂起,因为它无法解析主机名。
我尝试在这些规则中使用127.0.0.53作为DNS名称服务器。
我尝试允许DNS进入/从任何地方:
iptables -A INPUT -p udp --sport 53 -j ACCEPT
iptables -A INPUT -p udp --dport 53 -j ACCEPT
iptables -A OUTPUT -p udp --sport 53 -j ACCEPT
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT我的解决方案是apt remove systemd-resolved
IPTables脚本在安装systemd-resolved时如何进行名称解析?
发布于 2020-01-21 21:12:43
恐慌过去了,我用了排字--这些规则起作用
iptables -A INPUT -p udp --sport 53 -j ACCEPT
iptables -A INPUT -p udp --dport 53 -j ACCEPT
iptables -A OUTPUT -p udp --sport 53 -j ACCEPT
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT我试着让环回上的53号端口把东西拉紧。这是更好的安全对随机的bot IP DDOS?欢迎其他答案。
这些是我现在拥有的..。
iptables -A INPUT -p udp --sport 53 -m state --state ESTABLISHED -j ACCEPT
iptables -A INPUT -p udp --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPThttps://askubuntu.com/questions/1204733
复制相似问题