Added -hostn flag and environment variable to force custom local hostname. Useful for NAT.