Last active
March 8, 2020 12:07
-
-
Save alex21289/6ac74d29ca290791d6971969512709b6 to your computer and use it in GitHub Desktop.
Network/Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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