1

This is how my setting looks:

enter image description here

H2 and H4 are on separate networks. They have private IPs and not routable from outside the network. How do I make these two systems as peers so that they operate on the same private blockchain network? I tried using Public IP in the enode URI with the addPeer() function but the connection was not successful.

Edit:

As @Badr suggested, --nat with extip worked, but this cannot be used for connecting two systems with the same public IP i.e., the public IP cannot be translated to two private IPs. I tried using a different port # but the connection wasn't successful. Is there any solution for this?

galahad
  • 3,920
  • 3
  • 26
  • 66

2 Answers2

3

Ethereum clients use a listener (TCP) port and a discovery (UDP) port, both on 30303 by default.

Which TCP and UDP ports are required to run an Ethereum client?

as a firt try use the option

  --nat value       NAT port mapping mechanism (any|none|upnp|pmp|extip:<IP>) (default: "any")

https://github.com/ethereum/go-ethereum/wiki/Command-Line-Options

as a second choice : I think you should make some NAT redirection at the routers level. you need to forward the ports(default) 30303 and 8545(RPC) ports to the Hx machines

on R1

128.195.4.119:30303=>10.0.1.3:30303

128.195.4.119:8545=>10.0.1.3:8545

on R2

128.143.7.21:30303 =>192.168.1.1:30303

128.143.7.21:8545=>192.168.1.1:8545

then just use the public address when adding peers to the ethereum clients e.g enode://*******:128.143.7.21:30303

aditional information in the official doc we found this :

In the following example, the node URL describes a node with IP address 10.3.58.6, TCP listening port 30303 and UDP discovery port 30301.

enode://6f8a80d14311c39f35f516fa664deaaaa13e85b2f7493f37f6144d86991ec012937307647bd3b9a82abe2974e1407241d54947bbb39763a4cac9f77166ad92a0@10.3.58.6:30303?discport=30301

in this case consider to forward the port 30301 too.

Badr Bellaj
  • 18,780
  • 4
  • 58
  • 75
  • 1
    --nat with extip worked, but this cannot be used for connecting two systems with the same public ip. I tried using a different port # but the connection wasn't successful. Is there any solution for this? – galahad Sep 25 '16 at 19:52
0

How did you build the H5 node? In particular, you should be careful in not copying the ethereum wholesale. Closer to the point:

  • the nodekey file uniquely identifies your node.
  • it prevents a node from connecting back to itself.
  • if the same key is placed into 2 different nodes, these nodes will not connect to each other as they believe their are the same machine.

A test to make from H2:

  • stop Geth
  • delete nodekey file
  • start Geth
  • addPeer(H5)