To get the local fixed IP address, I use:
IP_ADDRESS = socket.gethostbyname(socket.getfqdn())
When I run this command on a DHCP client host, it returns '127.0.1.1'.
I know how to get it by parsing the result of ifconfig, but I would prefer to get it directly from python. Does anyone know how to get it?
[(s.connect(('8.8.8.8', 53)), s.getsockname()[0], s.close()) for s in [socket.socket(socket.AF_INET, socket.SOCK_DGRAM)]][0][1].