I've seen answers to this that include opening a connection to some source that doesn't need to be active. That seems like a waste of time and resources.
            Asked
            
        
        
            Active
            
        
            Viewed 384 times
        
    1 Answers
0
            
            
        This seems to be the easiest way to get the IP associated with the default route.
import socket    
hostname = socket.gethostname()
IPAddr = socket.gethostbyname(hostname)
DnsIPAddr = socket.gethostbyaddr(hostname)
print("Your Computer Name is:" + hostname)
print("Your Computer IP Address is:" + IPAddr)
print("According to DNS, your Computer IP Address is:" + DnsIPAddr)
 
    
    
        Clutch_Reboot
        
- 1
- 1
