Skip to content

Instantly share code, notes, and snippets.

@gabridome
Last active July 21, 2020 03:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabridome/8e0bf0975f6e6449d87b255cc6ea9481 to your computer and use it in GitHub Desktop.
Save gabridome/8e0bf0975f6e6449d87b255cc6ea9481 to your computer and use it in GitHub Desktop.
c-lightning on TOR a straightforward way to be visible on tor

C-LIGHTNING connected from inside your firewall in 60 lines

C-lightning is pretty rich in terms of options on how to be visible and/or how to reach other nodes in the lightning network.

The purpose of this article is to put you in the condition to be reached on the Tor network in the most straightforward way I am aware of, leaving more complex and reach configurations to deeper studies. You can find the documentation here.

It came out for me that Tor is also a very simple way to bypass network restrictions like firewall or protected routers and to be reachable with a non fixed IP number, so You can use this document if your node is inside a protected or otherwise restricted network, also if connected on DHCP.

To use Tor you have to have the service installed and running.

i.e. (on Linux Debian like distribution):

sudo apt install tor

then /etc/init.d/tor start or sudo systemctl start tor Depending on your system configuration.

sudo vi /etc/tor/torrc

Add the lines

ExitPolicy reject *:* # no exits allowed
ControlPort 9051
CookieAuthentication 1
CookieAuthFileGroupReadable 1

Just check that the keyword are not already active (uncommented) somewhere else on the file. Duplicate keywords may lead to unexpected behaviours.

Save the file and restart Tor

/etc/init.d/tor start or sudo systemctl restart tor

Now we can start the lightningd daemon adding the following options to the command line, if we DON'T want to announce our .onion address on the network: --bind-addr=autotor:127.0.0.1:9051 --proxy=127.0.0.1:9050

If we instead DO want to announce our brand new .onion address:

--addr=autotor:127.0.0.1:9051 --proxy=127.0.0.1:9050

That's it. No need for hacks to bypass NAT, no need to port forwarding or to methods to bypass firewall restrictions. You are now reachable on the Tor network even from inside a firewall.

If you are interested in knowing your address, you will get it with:

lightning-cli getinfo

The port is of course the number 9735.

Happy lightning everyone!

P.S.: I would like to stress the fact that this is just like a snippet to have your node exposed on Tor in minutes. Please dig into more complete configurations at the official documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment