Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: hazzey on April 07, 2011, 04:32:20 PM



Title: Two bitcoin clients behind NAT
Post by: hazzey on April 07, 2011, 04:32:20 PM
In my situation, I have two separate computers running the bitcoin client.  One has the firewall/NAT forwarding port 8333 to it and the other one is just behind the NAT.

What happens with the list of addresses that the network passes around?  My thinking is that since both of my computers appear to have the same global IP address, they are assumed to be the same computer. 

As an example, the NAT'd client connects out to its 8 other clients.  The NAT'd client's IP address gets added to the list of address that gets shared. When that address gets passed to another client that wants to connect, that client tries to connect to the IP address that it has.  Since the firewall/NAT forwards port 8333 to my second client, this client then receives the connection attempt and processes it.  The outside bitcoin client doesn't know the difference and is happy.

Is that how it would work?

This doesn't really make too much difference in the end, because the NAT'd client would only have ever connected out its 8 times anyway.  Would this in some way increase the number of connections that the port forwarded client gets?

My additional thought is that once the addresses of my two clients (they are the same IP) get passed around, they merge into one anyway and they client that has the port forward basically "becomes" the both of them.

Thanks for any of your thoughts.

Hazzey


Title: Re: Two bitcoin clients behind NAT
Post by: Matt Corallo on April 07, 2011, 05:17:32 PM
Please, dont wast network resources having two clients connect outside of your network.  The best way to do this is to run one client with the proper port forwarding, and then the second using the -connect= parameter, which limits connections to that particular peer (add your main node's local IP).

What happens with the list of addresses that the network passes around?  My thinking is that since both of my computers appear to have the same global IP address, they are assumed to be the same computer. 
Yep, pretty much.

As an example, the NAT'd client connects out to its 8 other clients.  The NAT'd client's IP address gets added to the list of address that gets shared. When that address gets passed to another client that wants to connect, that client tries to connect to the IP address that it has.  Since the firewall/NAT forwards port 8333 to my second client, this client then receives the connection attempt and processes it.  The outside bitcoin client doesn't know the difference and is happy.
Yea, in theory it should work just fine, you would be connecting to the other node on your network, no problems.  In reality, this would probably never happen (I dont think there is any "connecting to myself" checks, but I don't know) as there are so many nodes.

My additional thought is that once the addresses of my two clients (they are the same IP) get passed around, they merge into one anyway and they client that has the port forward basically "becomes" the both of them.
Yea, pretty much.


Title: Re: Two bitcoin clients behind NAT
Post by: hazzey on April 07, 2011, 05:59:51 PM
Please, dont wast network resources having two clients connect outside of your network.  The best way to do this is to run one client with the proper port forwarding, and then the second using the -connect= parameter, which limits connections to that particular peer (add your main node's local IP).

Ok, first, how is this wasting network resources.  Are you meaning that the NAT'd client is pointless because it is only connecting to 8 other nodes?  If that is the case, isn't every NAT'd client a waste?

Second, if I have the NAT'd client connect to another client on my local network (e.g. 192.168.*.*) won't the client see that as an invalid address and do its normal thing anyway?

Thanks,

Hazzey


Title: Re: Two bitcoin clients behind NAT
Post by: theymos on April 07, 2011, 06:40:31 PM
You'll send double the number of addr messages, which could help addr propagation slightly. Sending more addr messages has diminishing returns, as peers around you will block your duplicate messages. The main bootstrap method is IRC, though, and having two nicks on IRC doesn't give you any advantage.

In any case, it won't cause any problem for you or the network, aside from unnecessary resource usage.

Second, if I have the NAT'd client connect to another client on my local network (e.g. 192.168.*.*) won't the client see that as an invalid address and do its normal thing anyway?

No.