What I have done so far, using PyQt classes: all_Addresses = QNetworkInterface.allAddresses() #list-of-QHostAddress for addr in all_Addresses: print(addr.toString()) Output: 172.16.0.186 - Virtual Interface IP address 192.168.10.2 - Physical interface IP address. I want this one. 127.0.0.1 Using socket: import socket print(socket.gethostbyname(socket.gethostname())) Output: 172.16.0.186 - When openVPN is on 192.168.10.2 - When its off Is there a way to distinguish between them? Can this be done with ordinary Python, instead of using PyQt classes? How can I get the IPv6 address as well? Continue reading...