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

Classless zone (RFC 2317) name format #65

Open
Wallpix opened this issue Jul 12, 2023 · 6 comments
Open

Classless zone (RFC 2317) name format #65

Wallpix opened this issue Jul 12, 2023 · 6 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@Wallpix
Copy link

Wallpix commented Jul 12, 2023

There are 3 different format for sub class C arpa (reverse) zones.
I have an error parsing the following:

<octet4>/<mask>.<octet3>.<octet2>.<octet1>.in-addr.arpa

This is the error:

pyparsing.exceptions.ParseSyntaxException: , found '/'  (at char 35000), (line:1731, col:10)

Where the zone is something like this:

zone "128/27.0.0.10.in-addr.arpa" 

If I change the slash to a dash, it is parsed properly.

zone "128-27.0.0.10.in-addr.arpa" 

So the following notation works

<octet4>-<mask>.<octet3>.<octet2>.<octet1>.in-addr.arpa

But I was expecting the previous one to also work.
The 3rd annotation also works.

<address_range_from>-<address_range_to>.<octet3>.<octet2>.<octet1>.in-addr.arpa
@egberts
Copy link
Owner

egberts commented Jul 13, 2023

Dang.

This is really an issue of a specific string type used with only the zone name that is found in ISC Bind9 (as opposed to using valid DNS or IP-address convention).

In the string charset of its zone name, slash (and backslash) characters are prohibited in p arse_bind (or Bind9?) named-config-specific zone names for some reason and I need to find out why.

It is allowed in the ISC code base but it became (oh, I remember now) problematic for it is the PyParsing that is NOT ALLOWING slash/backslash charsetr in a Python string index names (as well as variable names).

Such example of Python string index name is:

zone['128/27.0.0.10.in-addr.arpa'].name

would NOT work because slash character does not work in Python index string.

But this one should work:

zone['128_27.0.0.10.in_addr.arpa'].name

Downside to a workaround is to remap the unsupported characters for usability within its Python index naming convention.

Additional studies tells me that this will be a hindrance in order to gain parsing capability of Bind9 ... with PyParsing and Python.

Simply remaping / into underscore will open up the risk of double mapping of zone names to same index; this approach is something I [will not, scratch that] might do just to comply with Python's index naming convention.

Pray tell, are you using some kind of automated tools that is generating these "esoteric" (but valid) zone names?

@Wallpix
Copy link
Author

Wallpix commented Jul 13, 2023

I came upon this zone format for a migration project of mine. This notation was most likely entered by a human. But Infoblox is also compliant with this naming (with slash). They use ISC BIND in the backend of their solution.

    zone "128/27.0.0.10.in-addr.arpa" in { # 128/27.0.0.10.in-addr.arpa
	type master;
	database infoblox_zdb;
	masterfile-format raw;
	file "azd/db.128#27.0.0.10.in-addr.arpa._default";
	notify yes;
    };

There probably should be some kind of error thrown for this saying something in the lines of "we do not support / in classless zone format, please replace with -". Or automate this transformation. At least the documentation should probably reflect this limitation.

@egberts egberts added bug Something isn't working good first issue Good for newcomers labels Jul 17, 2023
@egberts
Copy link
Owner

egberts commented Jul 17, 2023

Current design document

  • replacing slash(/) and backslash(\) into underscore ONLY for all zone names used, if any were found.
    • fairly easy to impement
  • output warning message during reading of parser that substitution "occurred".
    • this is harder since PyParsing offers little hook routines for interim (middle-of-parsing) actions.

@egberts
Copy link
Owner

egberts commented Jul 17, 2023

See StackOverflow by extraordinaire Paul McGuire (@ptmcg):

expr = Literal("/").setParseAction(replaceWith("_")) + "/"
print expr.parseString("zone "128/27.0.0.1 {};").asList()

More of those .replaceWith() methods used by other Open Source codes over here

@Wallpix
Copy link
Author

Wallpix commented Jul 21, 2023

I would change the slash ( / ) to a dash ( - ) for the nomination to be valid for Bind. I don't think underscore ( _ ) would parse properly in Bind.

@egberts
Copy link
Owner

egberts commented Dec 8, 2023

Underscore works well for zone name. Even square brackets too!!!

But i ran into some issues with other non-alphanum characters, and need to recheck on the minus symbol for used within this one named index used in Python array variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants