implements NAT handling facilities for Erlang applications
Erlang
65
61 commits
updated Jan 28, 2026
NAT traversal library for Erlang/OTP supporting UPnP IGD, NAT-PMP, and PCP protocols.
Full documentation: benoitc.github.io/erlang-nat
%% Add to your rebar.config
{deps, [{nat, "0.5.2"}]}.
%% Start the application
application:ensure_all_started(nat).
%% Discover NAT gateway
ok = nat:discover().
%% Get external IP
{ok, ExtIp} = nat:get_external_address().
%% Add port mapping (auto-renewed)
{ok, _Since, 8333, 8333, 3600} = nat:add_port_mapping(tcp, 8333, 8333).
%% Register for events
nat:reg_pid(self()).
receive
{nat_event, {ip_changed, OldIp, NewIp}} ->
io:format("IP changed: ~s -> ~s~n", [OldIp, NewIp])
end.
%% Delete mapping
ok = nat:delete_port_mapping(tcp, 8333, 8333).
MIT License - see LICENSE for details.
Erlang
98.2%
Shell
1.8%
implements NAT handling facilities for Erlang applications
Erlang
65
61 commits
updated Jan 28, 2026
NAT traversal library for Erlang/OTP supporting UPnP IGD, NAT-PMP, and PCP protocols.
Full documentation: benoitc.github.io/erlang-nat
%% Add to your rebar.config
{deps, [{nat, "0.5.2"}]}.
%% Start the application
application:ensure_all_started(nat).
%% Discover NAT gateway
ok = nat:discover().
%% Get external IP
{ok, ExtIp} = nat:get_external_address().
%% Add port mapping (auto-renewed)
{ok, _Since, 8333, 8333, 3600} = nat:add_port_mapping(tcp, 8333, 8333).
%% Register for events
nat:reg_pid(self()).
receive
{nat_event, {ip_changed, OldIp, NewIp}} ->
io:format("IP changed: ~s -> ~s~n", [OldIp, NewIp])
end.
%% Delete mapping
ok = nat:delete_port_mapping(tcp, 8333, 8333).
MIT License - see LICENSE for details.
Erlang
98.2%
Shell
1.8%