【问题标题】:iptables configuration to allow specific IP addresses and block the restiptables 配置以允许特定的 IP 地址并阻止其余的
【发布时间】:2020-06-19 11:17:31
【问题描述】:

我通过终端运行以下 iptables 命令,目的是只允许与一组 IP 地址进行通信,到目前为止,我无法做到这一点,并且由于我是 iptables 的新手而有点困惑。运行以下 curl 后无法访问 IP 地址/域名。这里可能有什么问题?

sudo iptables -P INPUT DROP

允许 DNS

sudo iptables -A INPUT -p udp --dport 53 -j ACCEPT

允许来自某个IP地址的请求

sudo iptables -A INPUT -p tcp --dport 443 -s 172.217.21.227 -j ACCEPT

【问题讨论】:

    标签: iptables


    【解决方案1】:

    iptables 规则取决于顺序,...如果您先删除所有 INPUT,则不会再处理其他 INPUT 规则。

    运行 sudo iptables -L 以查看您的 INPUT DROP 规则是否在前。

    如果是这样删除它sudo iptables -D INPUT DROP

    并将其重新添加到末尾sudo iptables -P INPUT DROP

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多