mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-27 10:58:37 -06:00
Reverse last commit for ipv6 reverse dns
This commit is contained in:
parent
2478b354d1
commit
89a0049532
@ -386,28 +386,19 @@ class Prefix(CreatedUpdatedModel):
|
|||||||
pslash = int(str(self.prefix).split('/')[1])
|
pslash = int(str(self.prefix).split('/')[1])
|
||||||
|
|
||||||
zslash = pslash if pslash % 16 == 0 else pslash/16+16
|
zslash = pslash if pslash % 16 == 0 else pslash/16+16
|
||||||
if pslash > zslash:
|
|
||||||
pslash = zslash
|
|
||||||
|
|
||||||
p = IPNetwork(unicode(pfull+'/'+str(pslash)))
|
|
||||||
|
|
||||||
ipaddresses = IPAddress.objects.filter(family=6)
|
|
||||||
for ip in ipaddresses:
|
for ip in ipaddresses:
|
||||||
ifull = str(ipaddress.IPv6Address(unicode(str(ip.address).split('/')[0])).exploded)
|
ifull = str(ipaddress.IPv6Address(unicode(str(ip.address).split('/')[0])).exploded)
|
||||||
inibbles = ifull.split(':')
|
inibbles = ifull.split(':')
|
||||||
idigits = ifull.replace(':','')[::-1]
|
idigits = ifull.replace(':','')[::-1]
|
||||||
islash = int(str(ip.address).split('/')[1])
|
islash = int(str(ip.address).split('/')[1])
|
||||||
|
|
||||||
i = netaddr.IPAddress(unicode(ifull))
|
pdigitszone = pdigits[:zslash/4][::-1]
|
||||||
|
zone_id = '.'.join(pdigitszone)+'.ip6.arpa.'
|
||||||
|
if not zone_id in zones:
|
||||||
|
zones[zone_id] = header(zone_id)
|
||||||
|
|
||||||
if i in p:
|
zones[zone_id] += ('.'.join(idigits[:32-zslash/4])).ljust(30)+' IN PTR ' + ip.hostname.ljust(40) + ' ; ' + ip.description.ljust(20) + ' ; gen by netbox ( '+time.strftime('%A %B %d %Y %H:%M:%S',time.localtime())+' ) \n'
|
||||||
|
|
||||||
pdigitszone = pdigits[:pslash/4][::-1]
|
|
||||||
zone_id = '.'.join(pdigitszone)+'.ip6.arpa.'
|
|
||||||
if not zone_id in zones:
|
|
||||||
zones[zone_id] = header(zone_id)
|
|
||||||
|
|
||||||
zones[zone_id] += ('.'.join(idigits[:32-pslash/4])).ljust(30)+' IN PTR ' + ip.hostname.ljust(40) + ' ; ' + ip.description.ljust(20) + ' ; gen by netbox ( '+time.strftime('%A %B %d %Y %H:%M:%S',time.localtime())+' ) \n'
|
|
||||||
|
|
||||||
|
|
||||||
for z in zones:
|
for z in zones:
|
||||||
|
Loading…
Reference in New Issue
Block a user