Closed frankcrawford closed 2 years ago
True... I've been bothered by this, but radvd does seem to cope. However, given that multiple addresses can have different lifespans, I should probably group them and pick the one with the longest life for reference...
Guess I'm going to have to finally figure out how to calc an ipv6 prefix in bash! (think I may just keep it simple and handle just the /64 case for now though :-)
I'll put up a pure bash script that calculates IPv6 prefixes it, that I put together the other day. Mainly because I put up this issue and then wondered how difficult it was. I did take the structure from another one, but that made heavy use of sed, etc, which I've now replaced with shell functions. Let me push it to github and I'll then let you know the repo details.
Have a look at this repo https://github.com/frankcrawford/bash_ipv6
That's great... I started work on one last night before I crashed, and used a script on stackoverflow as a starting point... It might have been yours :-) ... post was https://stackoverflow.com/a/50208987/14179001
I was busy converting it to a sed-less version as well, but your script looks very complete.... ok if I drop it in etc/nmutils to simplify distribution? (I'll add a link in it the source...)
Thanks for the patch. That was the same post I started with, and then moved to the original source it came from. It wasn't originally mine, but did give very good start and easy to convert to a sed-less version.
Yes, you can drop it into your distribution, as that is what I originally thinking, and then just kept adding functions.
I'll probably fix it up to handle subnets that are not a multiple of 4, but I doubt it is a big issue for your usage.
OK, I've updated 95-radvd-gen to group prefixes using your excellent function...(and added a few other fixes) - try it out and let me now if it correctly handles your configuration!
Thanks, have pulled it down and will test it in the next day or so.
Fixed a bug handling dynamic prefix overrides... best to test the latest version :)
Inspired by your ipv6 testsuite, I created one for radvd-gen... which in turn drove me to rewrite the file parser. It should be much easier to extend now in case the extensions you suggested in issue #6 ever come to light :)
FYI, I've just updated my bash IPv6 scripts to handle subnets much better. I may make a little more cleanup in the next day or two, but it probably won't change much going forward.
Looks like a nice addition...
I've been working on the testing (inspired by testing in bash_ipv6 :), and it grew to the point where I decided to break it out as it's own project... initial release is https://github.com/sshambar/shtest
With the tests added for nmutils (not checked in yet), I can add features and make sure I don't break the current scripts... so that work should be live on the "next" branch soon....
The current code includes a full test suite and has your script included. I'll close this issue, but feel free to re-open it again if you find any problems with the fix!
While radvd handles it okay, I notice that the @PREFIX@ setting is really putting in existing addresses, not shrinking to the minimum prefix, and as such, if the interface has multiple addresses with the same prefix (e.g. say XXX::1 and XXX:aa:bb:cc:dd) then there are two prefix statements generated.
Have you ever considered trying to extract the actual prefix value only and add it to your list?