Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipset_update_from_file is strict CIDR only for Nets and addfile is lax and imports both IP and CIDR into Nets IPsets #465

Open
ampersand-et opened this issue Sep 10, 2021 · 1 comment

Comments

@ampersand-et
Copy link

ampersand-et commented Sep 10, 2021

Found a bit of anomaly when using Firehol with IPSets when I started using a dynamic whitelist. This may have more to do with IPSet than Firehol but its above my head on how to dissect whats going on.

I use IP4 and IP6 NET ipsets and my file I load in has a mix of NETS and IPs. It works fine loading both CIDR and single IPs on initial loading of Firehol with:

ipv4 ipset create whitelist-ip4 hash:net
ipv4 ipset addfile whitelist-ip4 /some/path/whitelist-ip4.net
ipv6 ipset create whitelist-ip6 hash:net
ipv6 ipset addfile whitelist-ip6 /some/path/whitelist-ip6.net

If I were to update the same file again with a new single IP added to the source list:

firehol ipset_update_from_file whitelist-ip4 net  /some/path/whitelist-ip4.net
firehol ipset_update_from_file whitelist-ip6 net  /some/path/whitelist-ip6.net

Update_from_file will ignore any new single IP entries in the file. If I reload Firehol it will add both the CIDR and single IPs.

I understand I probably should use separate lists for single IPs and NETs but I was trying to keep less files and lists for simplicity or more likely laziness.

I switched my whitelist scripts to append a /32 or /128 on my single IPs going into the NET list and ipset_update_from_file is happy with that. I just found it strange how it is fine to load non CIDR into a NET on initialization of firehol but not when updating from file.

FireHOL 3.1.5 (3.1.5+ds-1ubuntu1)
ipset v7.5, protocol version: 7
Ubuntu 20.04.3 LTS

Cheers,
Ryan

@ampersand-et
Copy link
Author

Just realized this effects the updating of all the firehol blacklists since their .netset's are mixed addresses. Initial loading of Firehol loads everything on the lists fine. Update ignores new IP's and only updates new CIDR entries.

Whether strict or lax on mixing IP and CIDR, I think addfile and ipset_update_from_file both should be consistent on how they deal with it?

Maybe everyone else sorts the Firehol blacklists into separate IP and Net lists?

Cheers,
Ryan

@ampersand-et ampersand-et changed the title ipset_update_from_file acts different than addfile when loading mixed CIDR & single IPs into NET ipset ipset_update_from_file is strict CIDR only for Nets and addfile is lax and imports both IP and CIDR into Nets IPsets Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant