1

I am building a private chain and rpcaddr is set to 0.0.0.0
But recently I found out that this private chain has been attacked by a foreign IP, it kept trying to transfer those worthless ether out from my account.
The only external connection I need is connection to Metamask, so I was wondering is there any way that the geth only allow metamask to connect, while rpcaddr is set to localhost?

1
  • how about to use 127.0.0.1 address?
    – user55524
    Commented Aug 21, 2019 at 8:57

2 Answers 2

1

When you set rpcaddr set to 0.0.0.0, it means everyone can access it if they know your node's IP address. You have these options:

  1. If MetaMask and your node are on the same machine, just set the rpcaddr to 127.0.0.1 and only connections from the same machine will be allowed.
  2. If MetaMask and your node are on the same network, set rpcaddr to your local gateway address
  3. If they are both on the different networks you can set rpcaddr to IP address of your other machine (not recommended)
  4. Set authentication for your node
2
  • This was really helpful. For #2, is there a reason (such as security?) to set it to the local gateway address rather than simply the specific IP address of the host machine? I was able to make this work with the IP address of the host machine but not with the local gateway address of the network. When I attempted the latter, I got the error "bind: cannot assign requested address"
    – Gorgant
    Commented Dec 13, 2022 at 18:40
  • Also, FYI the docs have been updated so now its http.addr rather than rpc.addr: geth.ethereum.org/docs/rpc/server (please correct me if I'm wrong!)
    – Gorgant
    Commented Dec 13, 2022 at 18:50
0

What you need to do is pass --rpccorsdomain="metamask extension url" as well from your geth console.
Check this post to see how to do: https://metamask.zendesk.com/hc/en-us/articles/360015290012-Using-a-Local-Node

1
  • FWIW I was able to get this to work without specifying the corsdomain. I tried both ways (with and without) and it worked regardless, at least when interacting with Metamask.
    – Gorgant
    Commented Dec 13, 2022 at 18:48

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.