Skip to content

Instantly share code, notes, and snippets.

@alex21289
Last active March 8, 2020 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alex21289/6ac74d29ca290791d6971969512709b6 to your computer and use it in GitHub Desktop.
Save alex21289/6ac74d29ca290791d6971969512709b6 to your computer and use it in GitHub Desktop.
Network/Python
import socket
def main():
def get_IP():
try:
host_name = socket.gethostname()
host_ip = socket.gethostbyname(host_name)
host_fqdn = socket.getfqdn()
return host_name, host_fqdn, host_ip
except:
print("Unable to get Hostname and IP")
host = get_IP()
print("Host: "+host[0])
print("FQDN: "+host[1])
print("IP: "+host[2])
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment