import socket


def ipaddr_str(t):
    """Pass through a string provided it represents an ip address (not a host name) otherwise raise an exception"""
    try:
        socket.inet_aton(t)
    except socket.error:
        raise ValueError("IP address string not of the form nnn.nnn.nnn.nnn")
    return t