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?
-
how about to use 127.0.0.1 address?– user55524Commented Aug 21, 2019 at 8:57
Add a comment
|
2 Answers
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:
- 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. - If MetaMask and your node are on the same network, set rpcaddr to your local gateway address
- If they are both on the different networks you can set rpcaddr to IP address of your other machine (not recommended)
- Set authentication for your node
-
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"– GorgantCommented 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!)– GorgantCommented Dec 13, 2022 at 18:50
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
-
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.– GorgantCommented Dec 13, 2022 at 18:48