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?