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
- Raises
ValueError – When IP address is invalid
BoundaryException – When boundary for IPv4/v6 is invalid
- 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