Iptables

iptables range is reversed and will never match

2 minute read Modified:

This blogpost was original posted on Capitar’s blog

The problem

When customers ask us to allow some IP addresses to their services they might give us an IP-range in the following way.

10.0.0.1-6

This means they want the following IP addresses to have access: 10.0.0.1, 10.0.0.2, 10.0.0.3, 10.0.0.4, 10.0.0.5 and 10.0.0.6. But when you use this notation with iptables it gives an warning.

# iptables -A INPUT -m iprange --src-range 10.0.0.1-6 -j ACCEPT
xt_iprange: range 10.0.0.1-6 is reversed and will never match

This message is not displayed when 10.0.0.1-16 is used, although this will not result in the expected result.

Recent posts
- full list -