大网数据广告活动
服务器运维问答

Why does ipset succeed on adding ipv4 ranges, but fail on adding ipv6 range?

· 52CE 我爱测

Using ipset to clean up bulky iptable rulesets does not seem so different between IPv4 and IPv6 : # ipset create TEST hash:net family inet # ipset create DEMO hash:net family inet6 # iptables -A INPUT -m set --match-set TEST src …

问题原文

原帖链接 · anx · CC BY-SA 4.0

Using ipset to clean up bulky iptable rulesets does not seem so different between IPv4 and IPv6:

# ipset create TEST hash:net family inet
# ipset create DEMO hash:net family inet6
# iptables -A INPUT -m set --match-set TEST src -j DROP
# ip6tables -A INPUT -m set --match-set DEMO src -j DROP

However, upon adding ip ranges, unexpected errors occur only for IPv6 ranges:

# ipset add TEST 192.0.2.0-192.0.2.127
# ipset add DEMO 2001:db8::-2001:db8::ffff
ipset v6.34: Syntax error: IP address or IP/cidr must be specified: 2001:db8::-2001:db8::ffff

This is unexpected, as ipset appears to be able to parse these IPv6 addresses:

# ipset add DEMO 2001:db8::/112
# ipset del DEMO 2001:db8::/112
# ipset add DEMO 2001:db8::ffff/112
# ipset -L DEMO | tail -2
Members:
2001:db8::/112

Why would ipset accept fromaddr-toaddr ranges for IPv4 but consider the same thing a syntax error for IPv6?

已采纳解答

原帖链接 · anx · CC BY-SA 4.0

The fromaddr-toaddr syntax is only supported for IPv4. Use cidr notation to add IPv6 ranges.

For the inet family one can add or delete multiple entries by specifying a range or a network of IPv4 addresses in the IP address part of the entry - man 8 ipset

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-09-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。