#!/usr/bin/python3
#============================================================================
# Title       : ipaddr
# Description : returns the default IP address for the host
# Author      : Bart Sjerps <bart@dirty-cache.com>
# License     : GPLv3+
# ---------------------------------------------------------------------------

import socket as _socket

def ipaddr():
    s = _socket.socket(_socket.AF_INET, _socket.SOCK_DGRAM)
    try:
        s.connect(('10.255.255.255', 1))
        ip = s.getsockname()[0]
    except:
        ip = '127.0.0.1'
    finally:
        s.close()
    return ip

print (ipaddr())
