import socket hostname = socket.gethostname() IPinfo = socket.gethostbyname_ex(hostname) LocalIP = IPinfo[2][2] print LocalIP