如何使用 iptables 限制 SSH 访问特定 IPv6 地址?

如何使用 iptables 限制 SSH 访问特定 IPv6 地址?

我对 ipv4 应用了以下两条规则:

-A INPUT -s 5.70.139.172/32 -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j REJECT --reject-with icmp-port-unreachable

以上适用于 ipv4。

我已经安装了 ip6tables 软件包,并且尝试将这两行(将 ipv4 地址替换为 ipv6)复制到默认的 ip6tables 配置文件中。然而这些改变似乎并没有生效?

这是因为可能使用了firewalld吗?

systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2018-06-22 16:05:41 UTC; 1h 47min ago
     Docs: man:firewalld(1)
 Main PID: 507 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─507 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Jun 22 16:49:37 li1663-14.members.linode.com firewalld[507]: ERROR: Failed to load '/etc/sysconfig/network-scripts/ifcfg-eth0': [Errno 13] Permission denied: ...fg-eth0'
Jun 22 16:49:37 li1663-14.members.linode.com firewalld[507]: ERROR: Calling post func <function ifcfg_set_zone_of_interface at 0x7f353247caa0>(('public', 'eth...fg-eth0'
Jun 22 16:49:51 li1663-14.members.linode.com firewalld[507]: ERROR: Failed to load '/etc/sysconfig/network-scripts/ifcfg-eth0': [Errno 13] Permission denied: ...fg-eth0'
Jun 22 16:49:51 li1663-14.members.linode.com firewalld[507]: ERROR: Calling post func <function ifcfg_set_zone_of_interface at 0x7f353247caa0>(('public', 'eth...fg-eth0'
Jun 22 16:52:05 li1663-14.members.linode.com firewalld[507]: ERROR: Failed to load '/etc/sysconfig/network-scripts/ifcfg-eth0': [Errno 13] Permission denied: ...fg-eth0'
Jun 22 16:52:05 li1663-14.members.linode.com firewalld[507]: ERROR: Calling post func <function ifcfg_set_zone_of_interface at 0x7f353247caa0>(('public', 'eth...fg-eth0'
Jun 22 17:46:11 li1663-14.members.linode.com firewalld[507]: ERROR: Failed to load '/etc/sysconfig/network-scripts/ifcfg-eth0': [Errno 13] Permission denied: ...fg-eth0'
Jun 22 17:46:11 li1663-14.members.linode.com firewalld[507]: ERROR: Calling post func <function ifcfg_set_zone_of_interface at 0x7f353247caa0>(('public', 'eth...fg-eth0'
Jun 22 17:51:58 li1663-14.members.linode.com firewalld[507]: ERROR: Failed to load '/etc/sysconfig/network-scripts/ifcfg-eth0': [Errno 13] Permission denied: ...fg-eth0'
Jun 22 17:51:58 li1663-14.members.linode.com firewalld[507]: ERROR: Calling post func <function ifcfg_set_zone_of_interface at 0x7f353247caa0>(('public', 'eth...fg-eth0'
Hint: Some lines were ellipsized, use -l to show in full.

我用的是centos 7。

答案1

您需要安装 ip6tables 软件包。 iptables 仅适用于 ipv4 地址。您需要创建一个包含 ipv6 规则的新配置。

相关内容