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?

9
  • does the router support Upnp?
    – Badr Bellaj
    Commented Sep 23, 2016 at 11:03
  • @Badr Yes, it supports Upnp.
    – galahad
    Commented Sep 28, 2016 at 5:41
  • i didn't understand that you have tow separate networks(as in the figure) with the same public ip?
    – Badr Bellaj
    Commented Oct 3, 2016 at 20:08
  • how do you add nodes? did you get the info using admin.nodeInfo to check ip? did you tried --nat upnp or any
    – Badr Bellaj
    Commented Oct 3, 2016 at 20:18
  • @Badr the two separate networks have different public ips. My problem is that I can do NAT and assign this public ip only to one of the systems in that network.
    – galahad
    Commented Oct 3, 2016 at 23:56

2 Answers 2

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.

1
  • 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
    Commented Sep 25, 2016 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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.