ip_to_rdns

privex.helpers.net.ip_to_rdns(ip: str, boundary: bool = False, v6_boundary: int = 32, v4_boundary: int = 24)str[source]

Converts an IPv4 or IPv6 address into an in-addr domain

Default boundaries: IPv4 - 24 bits, IPv6 - 32 bits

Examples:

>>> ip_to_rdns('127.0.0.1') # IPv4 to arpa format
    '1.0.0.127.in-addr.arpa'
>>> ip_to_rdns('2001:dead:beef::1') # IPv6 to arpa format
    '1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.f.e.e.b.d.a.e.d.1.0.0.2.ip6.arpa'
>>> ip_to_rdns('2001:dead:beef::1', boundary=True) # IPv6 32-bit boundary to arpa
    'd.a.e.d.1.0.0.2.ip6.arpa'
Parameters
  • ip (str) – IPv4 or IPv6 address

  • boundary (bool) – If True, return the base (boundary) domain to place NS/SOA

  • v6_boundary (int) – Bits for IPv6 boundary. Must be dividable by 4 bits (nibble)

  • v4_boundary (int) – Bits for IPv4 boundary. Must be dividable by 8 bits (octet)

Raises
Return str rdns_domain

in-addr.arpa format, e.g. 0.0.127.in-addr.arpa

Return str rdns_domain

ip6.arpa format, e.g. 0.8.e.f.ip6.arpa