[erlang-questions] Simple NAT traversal

Michael Santos michael.santos@REDACTED
Wed Feb 1 14:47:37 CET 2012

On Wed, Feb 01, 2012 at 12:25:02AM -0800, eigenfunction wrote:
> Hi everybody,
> i have an erlang application running behind a nat. Now i have come to
> a point where i need to know my public ip. I was thinking about
> running a tiny tcp server behind the nat whose sole purpose would be
> to send me my public ip. My question is this: isn't there a more
> simple alternative? Heck, even if i could determine the public ip of
> the NAT device without doing a "backflip" it will be enough for my
> case.
> Any idea?

You could ask a 3rd party service:

1> inets:start().
2> URL = "http://automation.whatismyip.com/n09230945.asp".
3> {ok, {{"HTTP/1.1",200,"OK"}, _Headers, Body}} = httpc:request(URL).
      {"date","Wed, 01 Feb 2012 13:15:10 GMT"},
4> inet_parse:address(Body).

Google will show you your public IP too:


More information about the erlang-questions mailing list