If you want to get the IP address of whichever interface is used to connect to the network without having to know its name, you can use this: import socketdef get_ip_address():s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)s.connect(("8.8.8.8", ...