iptables環回打開所有端口

iptables環回打開所有端口

我的 iptables 和環回介面有一個奇怪的問題。

ifconfig 說:

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>

對於 ipv6 和 ipv4 規則,我使用這個:

-A INPUT -i lo -j ACCEPT

對於 ipv6 它工作正常:

Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     all      ::/0                 ::/0                 state RELATED,ESTABLISHED
ACCEPT     all      ::1                  ::1

但對於 ipv4,它打開所有連接埠:

Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0

所需的解決方案由以下人員存檔:

-A INPUT -s 127.0.0.1 --dst 127.0.0.1 -i lo -j ACCEPT

但為什麼將規則綁定到介面 lo 對 ipv4 不起作用,但對 ipv6 卻完美無缺?

相關內容