Skip to content

Fix the reverse look zone look up to handle non /24 CDIR #8

Open
cho00013 opened this issue Feb 5, 2022 · 1 comment
Open

Fix the reverse look zone look up to handle non /24 CDIR #8

cho00013 opened this issue Feb 5, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@cho00013
Copy link
Contributor

cho00013 commented Feb 5, 2022

Currently the code only handles if the PTR zone is 255.255.255.0. That should be fine for Census but I think to make the code more complete, it should also be able to handle /16.

@cho00013 cho00013 added the enhancement New feature or request label Feb 5, 2022
@badra001
Copy link
Contributor

badra001 commented Feb 7, 2022

In DNS, the zones for IPv4 are created only for /24 boundaries. You can get this from the ipaddress python module

import ipaddress

ip=ipaddress.ip_address(ip_address_string)
rev_ip=ip.reverse_pointer
v=ip.version

if v==4:
  np='.'.join(p.split('.')[1:])
elif v==6:
  np='.'.join(p.split('.')[16:])
else:
  np='undefined'

# np is the string for the PTR zone, either ipv4 format (/24) or ipv6 format (/64).

We do want to make sure we can extend this for IPv6 easily.

Sign in to join this conversation on GitHub.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants