Why satoshi client's UPnP part maps to a fixed external port (8333 by default)? If there are multiple clients behind the NAT router, won't there be a conflict?
-
Doesn't a router route to specific ip addresses? So multiple clients behind a router won't be a problem unless they have conflicting ip addresses.– John TCommented Feb 12, 2014 at 6:08
-
They have different internal IP, but may have the same external IP.– updogliuCommented Feb 12, 2014 at 6:16
-
A router runs connection tracking software to make sure all connected in the network get differentiated.– John TCommented Feb 12, 2014 at 6:23
-
I don't understand. If a peer from outside want to connect (external_ip, 8333), how can the router tell which internal ip should it forward to?– updogliuCommented Feb 12, 2014 at 6:31
-
It's a long Wikipedia article on how exactly it's done but it's done in the same way you can browse (port 80) on the internet on two computer without loading pages another computer loads.– John TCommented Feb 12, 2014 at 6:54
1 Answer
A fixed external port is used so that other clients on the internet can connect to your client by knowing only your IP address. They will use the fixed port number to connect.
If you have multiple clients behind a NAT device, then only one client will be able to negotiate with the NAT device to listen on port 8333 (and have incoming connections translated to its client address).
Note that the above assumes the clients actually are behind a NAT devices (which is very common, especially in home networking setups). If instead the router is really just a router and not a NAT device, then each client behind the router will have its own public IP address, and there won't be any conflict between more than one of them listening at the same time on port 8333.
-
Is there a viable solution for having multiple clients behind the same NAT? Can the satoshi client peer advertise itself with another port if required? Commented Feb 12, 2014 at 12:47
-
1@LordOfThePigs Yes, you can change the listen port. Specify 'port=nnnnn' in bitcoin.conf to use another port. Commented Feb 12, 2014 at 15:54