btc1 / bitcoin

btc1 project bitcoin implementation
MIT License
329 stars 55 forks source link

Client (bitcoin-cli) connects over IPv4, but server is listening on IPv6 #110

Closed jprupp closed 4 years ago

jprupp commented 7 years ago

I setup a Raspberry Pi as my secondary BTC1 node. I expect that once Bitcoin upgrades to 2MB blocks that node will continue working fine.

I am facing a curious problem that was not happening while the network interface was wlan0 in a local network, but it has started to affect the device since I connected it via the eth0 interface with a public IP address. The wireless dongle that was originally wlan0 is now gone.

The issue is that when I type any bitcoin-cli commands, I get this error:

error: couldn't connect to server: unknown (code -1)
(make sure server is running and you are connecting to the correct RPC port)

I must specify --rpcconnect=::1 in the bitcoin-cli command line so that it connects to the localhost IPv6 address instead of 127.0.0.1.

$ netstat -nlp --inet --inet6
(No info could be read for "-p": geteuid()=1001 but you should be root.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:8333            0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      -               
tcp        0      0 0.0.0.0:18555           0.0.0.0:*               LISTEN      -               
tcp6       0      0 ::1:8332                :::*                    LISTEN      -               
tcp6       0      0 :::8333                 :::*                    LISTEN      -               
tcp6       0      0 :::22                   :::*                    LISTEN      -               
tcp6       0      0 ::1:18554               :::*                    LISTEN      -               
tcp6       0      0 :::18555                :::*                    LISTEN      -               
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           -               
udp        0      0 0.0.0.0:54161           0.0.0.0:*                           -               
udp        0      0 0.0.0.0:68              0.0.0.0:*                           -               
udp        0      0 31.187.34.77:123        0.0.0.0:*                           -               
udp        0      0 127.0.0.1:123           0.0.0.0:*                           -               
udp        0      0 0.0.0.0:123             0.0.0.0:*                           -               
udp6       0      0 :::5353                 :::*                                -               
udp6       0      0 :::53542                :::*                                -               
udp6       0      0 fe80::eae5:ef11:3fa:123 :::*                                -               
udp6       0      0 ::1:123                 :::*                                -               
udp6       0      0 :::123                  :::*                                -               
raw6       0      0 :::58                   :::*                    7           -               

I wonder why there are there discrepancies between bitcoin-cli and bitcoind when it comes to selecting the IP address to use in order to create or connect to the locally-running RPC server. This issue might also affect Bitcoin Core.

argon2 commented 7 years ago

Bitcoin does not currently support dual-stack IP (it uses IPv4 mapped addresses only). We have implemented it and will make a pull request. This allows your node to be both IPV4 and IPV6 at the same time thus bridging the gap between IPv4 and IPv6 nodes.

maddenw commented 7 years ago

IPv6? Now is not a good time.

argon2 commented 7 years ago

Our non-satoshi full node runs dual-stack (both IPv4 and IPv6). It has no problems for 3.5 years now with IPv6.