Skip to content

Instantly share code, notes, and snippets.

@Esl1h
Created August 18, 2020 01:20
Show Gist options
  • Save Esl1h/c40b1b6afa529e35e930da5429b8f4f0 to your computer and use it in GitHub Desktop.
Save Esl1h/c40b1b6afa529e35e930da5429b8f4f0 to your computer and use it in GitHub Desktop.
Python converting decimal to IPv4 using ipaddress module (in databases IPv4 are recorded as decimal, mostly.
#!/usr/bin/python3.8
import ipaddress
decip = 2887123457 # Example for 172.22.2.1
ip = str(ipaddress.IPv4Address(decip))
print(ip)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment