Zcashd with --connect to a single IP adds a second connection

I have a full node that has been running for quite a while and everything is running fine. On a second machine on my private network, I start up a second full node and I use the connect option to specify that I am only connecting to my public node (using the internal address), like so:

zcashd -conf=zcash.conf -connect=192.168.17.105

Everything looks normal and the node has only one connection and it gets all the latest blocks. However after some period of time has past, I notice that it has two connections. An outgoing connection to an external address has been added. I did not issue any commands between startup and noticing that there were two connections.

Am I misunderstanding the -connect option with a single IP? I was expecting that the daemon would not initiate any connections besides to that one IP.

When I do “zcash-cli getpeerinfo” I see:

[
{
“id”: 1,
“addr”: “192.168.17.105”,
“services”: “0000000000000005”,
“lastsend”: 1526144103,
“lastrecv”: 1526144103,
“bytessent”: 6592,
“bytesrecv”: 690177,
“conntime”: 1526143684,
“timeoffset”: 50,
“pingtime”: 0.000849,
“version”: 170005,
“subver”: “/MagicBean:1.1.0/”,
“inbound”: false,
“startingheight”: 322072,
“banscore”: 0,
“synced_headers”: 322075,
“synced_blocks”: 322075,
“inflight”: [
],
“whitelisted”: false
},
{
“id”: 4,
“addr”: “104.236.180.231:8233”,
“addrlocal”: “xx.xxx.xx.xxx:xxxxx”,
“services”: “0000000000000001”,
“lastsend”: 1526144103,
“lastrecv”: 1526144053,
“bytessent”: 5561,
“bytesrecv”: 80892,
“conntime”: 1526143925,
“timeoffset”: 50,
“pingtime”: 0.026707,
“version”: 170003,
“subver”: “/MagicBean:1.0.15/”,
“inbound”: false,
“startingheight”: 322073,
“banscore”: 0,
“synced_headers”: 322075,
“synced_blocks”: 322075,
“inflight”: [
],
“whitelisted”: false
}
]

I am running zcashd version v1.1.0 on Ubuntu 16.04.

Do you have addnode set in your config file?

I do, to mainnet. But if it goes by what’s in the config file, then what’s the purpose of the -connect option?

I don’t know but I am guessing it uses both so just set the connect option and not addnode and see if that works?

This IP address resolves to mainnet.z.cash.

As @garethtdavies points out, you probably have addnode=mainnet.z.cash in your zcash.conf.

I think the help information for -connect is misleading by saying it will “connect only to the specified node(s)”. Looking at the source code (the best way to figure these things out!) – it is clear that it will also open connections to “added nodes”, i.e. those nodes specified using addnode either in the configuration file, command line, or RPC. It will not open additional unspecified connections automatically if -connect is used.

2 Likes

Thanks for the clarification and thanks for taking time to look at the source!

Also by default zcashd will contact the dns seeders to try and find peers. To disable this behaviour, launch as zcashd -dnsseed=0 or place this option in your config file.

1 Like