lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.72k stars 2.09k forks source link

Automatic NAT hole punching #185

Closed Roasbeef closed 6 years ago

Roasbeef commented 7 years ago

Currently, the only way for lnd to advertise it's reachable public IP address is for the user to manually specify it using the externalip flag either on the command line or in the configuration file. However, due to the existence of NATs this can be inadequate. As a result, many users won't be able to accept any inbound channel requests unless they're not behind a NAT, or are able to manually configure the gateway in their local network.

In order to complete this issue, automatic UDP hole punching should be implemented within the daemon either using UPnP, STUN/TURN methods, or something else entirely (hidden services?). The following golang libraries may be of interest:

insunaa commented 6 years ago

Does this also solve the issue that peers behind a NAT with a daily IP change are unable to accept incoming channels? I can run bitcoind and it will do auto-discovery and will just start accepting connections again after an IP change, but the way I understood it, lnd will block incoming channels completely if externalip is not set. Can it be set to a dummy value like 255.255.255.255 or 0.0.0.0? Please excuse my ignorance.