<p>This is implementation dependent of course. Afaik every implementation will try to reconnect, so your first case works (note that your paranoid friend's Tor hidden service isn't used at all). This is common in practice, for any non-public node.</p>

<p>In the second case, for c-lightning the address hint will be forgotten on reconnect, so they'll try to reconnect on the public IPs. Even if we were to fix that, they'll try so the addresses including the public ones: we'd need a special option to ignore public addresses for a specific node if this were common.</p>

CC BY-SA 4.0
2019-09-22T05:02:38.603Z
That is the interesting part - how exactly the node implementations will reconnect. In which order, and will they do that successfully in described cases. If I understood you (and prev. commenter) correct friends node will going to reconnect to my node anyway on start-up.

I understand that my friends .onion address was not used in that described case, but anyway, it is available for others and he is proxying over TOR outgoing connections.

I was also thinking would it be good in c-lightning to specify proxy setting to some specific hosts only (IP range, .onions). Now it is ON xor OFF.
baysx
CC BY-SA 4.0
2019-09-23T06:17:57.353Z
Thanks, I've opened an issue: https://github.com/ElementsProject/lightning/issues/3085
Rusty Russell
CC BY-SA 4.0
2019-09-21T01:00:37.397Z
2019-09-21T01:25:23.567Z
2019-09-21T01:25:23.567Z
Rusty Russell
<p>So I have a question regarding network connectivity within LN nodes. </p>

<p><strong>Scenario #1:</strong></p>

<p>I have public lightning network node. it has real public IP address (let's say 123.123.123.123), which one is announced in config file. also, there is a TOR service, with configured .onion service (let's say mynode.onion). On the nodes config file <strong>there is no proxy configuration</strong>, so my node communicates with the rest of the world using clearnet. So from the outside world my node is available on 123.123.123.123:9735 and mynode.onion:9735. While outgoing connections are made from 123.123.123.123.</p>

<p>Now I have a friend, who's also node operator. He's a paranoid (his node is only available as a TOR hidden service on friendsnode.onion) and needs some incoming capacity. As i understand (please correct me if i am wrong), the only way to open channel to him is possible that way:</p>

<ul>
<li>connect from my friends node to my node using my clearnet IP
123.123.123.123</li>
<li>connect from my node to friends node using his node ID</li>
<li>open a channel to him, using his node ID</li>
</ul>

<p>my question is: </p>

<ol>
<li>what will happen in case of node restart or any other accidental event which can interrupt the current connection. </li>
<li>Will the nodes re-connect to each other without any manual operations?</li>
</ol>

<p><strong>Scenario #2:</strong></p>

<p>I have two LN nodes on my LAN. each node has its local IP (let's say NodeA - 192.168.0.1 and NodeB - 192.168.0.2) and both nodes have their dedicated public ip (let's say 5.5.5.5 and 6.6.6.6). The nodes have in their config files announcing the real IPs, not local ones. I would like to create a channel NodeA -> NodeB, but want to do so using local addresses. So what i do:</p>

<ul>
<li>on NodeA connect to NodeB id@192.168.0.2:9735</li>
<li>open a channel NodeA -> NodeB</li>
</ul>

<p>my question is:</p>

<ol>
<li>will it connect at all (not tested, but i assume - yes)</li>
<li>will the nodes reconnect correctly on restart? (is the NodeB connection network address stored in DB/config files on NodeA or is it retrieved from "announced" addresses somehow from NodeB each time? )</li>
<li>will be the LAN address of any node somehow visible to rest of the network? (assuming that beside NodeA&lt;->NodeB channel there are non-related channels to  third-party public node from each node as well)</li>
</ol>

<p>Appreciate your answers!</p>

<p>edit: formatted &amp; fixed some typo</p>

CC BY-SA 4.0
2019-09-19T13:26:37.547Z
i got an answer in telegram from one guy, so there it is:

it is more iportant public key matching and how nodes connected doesn’t matter, when you try to open channel and any other operation which involve p2p communication, node first tries to find public key in active connections, then establish connection directly to ip address taken from graph cache (each node broadcast their advertised ip addres to the network, for lnd this is --externalip parameter), then in local cahce of previous successful connection...
baysx
CC BY-SA 4.0
2019-09-19T13:28:30.847Z
...when you open a chennel with a node, and then restart both nodes, after restart each of node will try to connect to each other from both sides, infinitely

please confirm someone this
baysx
<lightning-network><network>
Networking & Lightning Network
baysx
# Networking & Lightning Network

(Asked by: username_0 on 2019-09-19)

So I have a question regarding network connectivity within LN nodes.

**Scenario #1:**

I have public lightning network node. it has real public IP address (let's say 123.123.123.123), which one is announced in config file. also, there is a TOR service, with configured .onion service (let's say mynode.onion). On the nodes config file **there is no proxy configuration**, so my node communicates with the rest of the world using clearnet. So from the outside world my node is available on 123.123.123.123:9735 and mynode.onion:9735. While outgoing connections are made from 123.123.123.123.

Now I have a friend, who's also node operator. He's a paranoid (his node is only available as a TOR hidden service on friendsnode.onion) and needs some incoming capacity. As i understand (please correct me if i am wrong), the only way to open channel to him is possible that way:

* connect from my friends node to my node using my clearnet IP
  123.123.123.123
* connect from my node to friends node using his node ID
* open a channel to him, using his node ID

my question is:

1. what will happen in case of node restart or any other accidental event which can interrupt the current connection.
2. Will the nodes re-connect to each other without any manual operations?

**Scenario #2:**

I have two LN nodes on my LAN. each node has its local IP (let's say NodeA - 192.168.0.1 and NodeB - 192.168.0.2) and both nodes have their dedicated public ip (let's say 5.5.5.5 and 6.6.6.6). The nodes have in their config files announcing the real IPs, not local ones. I would like to create a channel NodeA -> NodeB, but want to do so using local addresses. So what i do:

* on NodeA connect to NodeB id@192.168.0.2:9735
* open a channel NodeA -> NodeB

my question is:

1. will it connect at all (not tested, but i assume - yes)
2. will the nodes reconnect correctly on restart? (is the NodeB connection network address stored in DB/config files on NodeA or is it retrieved from "announced" addresses somehow from NodeB each time? )
3. will be the LAN address of any node somehow visible to rest of the network? (assuming that beside NodeA<->NodeB channel there are non-related channels to third-party public node from each node as well)

Appreciate your answers!

edit: formatted & fixed some typo

**Tags:** lightning-network, network

> **Comments:**
> **username_0**: i got an answer in telegram from one guy, so there it is:  it is more iportant public key matching and how nodes connected doesn’t matter, when you try to open channel and any other operation which involve p2p communication, node first tries to find public key in active connections, then establish connection directly to ip address taken from graph cache (each node broadcast their advertised ip addres to the network, for lnd this is --externalip parameter), then in local cahce of previous successful connection...  
> **username_0**: ...when you open a chennel with a node, and then restart both nodes, after restart each of node will try to connect to each other from both sides, infinitely  please confirm someone this  

---

## 1 answers

### Answer by username_1 on 2019-09-21. Score: 1

This is implementation dependent of course. Afaik every implementation will try to reconnect, so your first case works (note that your paranoid friend's Tor hidden service isn't used at all). This is common in practice, for any non-public node.

In the second case, for c-lightning the address hint will be forgotten on reconnect, so they'll try to reconnect on the public IPs. Even if we were to fix that, they'll try so the addresses including the public ones: we'd need a special option to ignore public addresses for a specific node if this were common.

> **Comments:**
> **username_0**: That is the interesting part - how exactly the node implementations will reconnect. In which order, and will they do that successfully in described cases. If I understood you (and prev. commenter) correct friends node will going to reconnect to my node anyway on start-up.  I understand that my friends .onion address was not used in that described case, but anyway, it is available for others and he is proxying over TOR outgoing connections.  I was also thinking would it be good in c-lightning to specify proxy setting to some specific hosts only (IP range, .onions). Now it is ON xor OFF.  
> **username_1**: Thanks, I've opened an issue: https://github.com/ElementsProject/lightning/issues/3085  

---

