Skip to content

firewall: Allow dynamic IPv6 prefixes in rules #3247

Description

@klada

Is your feature request related to a problem? Please describe.

Unfortunately many ISPs only hand out dynamic IPv6 prefixes. IPv6-enabled hosts/servers behind the firewall might have a static IPv6 interface address with a dynamic prefix part (e.g. assigned through ip tokens in Linux).

Right now it is impossible to add IPv6 firewall rules for individual hosts with dynamic prefixes.

Describe the solution you'd like

A trivial approach would be to match only the last 64 bits of an IPv6 address, thus ignoring the entire prefix. In Linux (with ip6tables) you can invert the network mask, so you ignore the prefix and only match the host part. This can be done like this:

ip6tables [...] -d ::192:168:20:1/0000:0000:0000:0000:ffff:ffff:ffff:ffff -o eth2 [...]
# or even sorter
ip6tables [...] -d ::192:168:20:1/!64  -o eth2 [...]

I think this is a very convenient approach which resolves most issues with changing prefixes in IPv6 firewall rules. I don't know if pf actually supports inverting the network mask, but if it does this would probably be the easiest way of supporting dynamic prefixes.

If the outbound interface could also be specified we wouldn't have to worry about address collision in situations where the host part is not unique across IPv6 subnets.

Describe alternatives you've considered

If matching the last 64 bits is not possible, a syntax like ${PREFIX_LAN}:192:168:20:1 for host aliases would probably also get the job done. The disadvantage would probably be that the aliases would need to be reloaded each time the tracked IPv6 address changes on the relevant interface.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions