Random ports in peer handshake

+1 vote
While looking at the output of getpeerinfo api call, there are random ports on addr and addr local fields. I have set the default network and RPC ports.

I have set the default network ports to be 6001 for both the nodes and connected the daemon by on the same port.

here is an example

[
    {
        "id" : 3,
        "addr" : "11.0.2.19:6001",
        "addrlocal" : "10.0.2.218:40384",
        "services" : "0000000000000001",
        "lastsend" : 1595145954,
        "lastrecv" : 1595145954,
        "bytessent" : 33682716,
        "bytesrecv" : 68302709,
        "conntime" : 1592493648,
        "pingtime" : 0.100124,
        "version" : 70002,
        "subver" : "/MultiChain:0.2.0.10/",
        "handshakelocal" : "1QEXPURG6es3LhbUNux2DELwwJyB1Jqvd9xnV4",
        "handshake" : "14MwcB2MQxLT9bcfUJR5vRrnJdJ8RWAeGGnVV5",
        "inbound" : false,
        "startingheight" : 2734,
        "banscore" : 0,
        "synced_headers" : 8676,
        "synced_blocks" : 8676,
        "inflight" : [
        ],
        "whitelisted" : false
    },
    {
        "id" : 28,
        "addr" : "10.0.4.238:59848",
        "addrlocal" : "10.0.2.218:6001",
        "services" : "0000000000000001",
        "lastsend" : 1595145954,
        "lastrecv" : 1595145953,
        "bytessent" : 6403475,
        "bytesrecv" : 356378,
        "conntime" : 1595140368,
        "pingtime" : 0.05432,
        "version" : 70002,
        "subver" : "/MultiChain:0.2.0.10/",
        "handshakelocal" : "1QEXPURG6es3LhbUNux2DELwwJyB1Jqvd9xnV4",
        "handshake" : "1ZqTLXmJHvWrvpTniZuT4vusFBS1XUqWrZxkLL",
        "inbound" : true,
        "startingheight" : 87,
        "banscore" : 0,
        "synced_headers" : 8675,
        "synced_blocks" : 8675,
        "inflight" : [
        ],
        "whitelisted" : false
    }
]

Is this normal behavior? Will it cause any problems if there are firewall rules in place that only allow communication through the default network port?

 

Thanks
asked Jul 19, 2020 by DarkBlaze

1 Answer

+1 vote
 
Best answer

This is normal for all kinds of connections over the Internet. When one node connects to another, it connects to the defined port 6001, but it connects from a random free port number. The firewall and the receiving node don't care about the port being connected from. The communication can still be two-way over a connection made in one direction.

answered Jul 19, 2020 by MultiChain
selected Jul 19, 2020 by DarkBlaze
Thanks got it.
...