I want to know what ports and protocols tezos-node and baker uses so that i can enable only those ports and protocols in my firewall setting to prevent any DDos attack on my server.


3 Answers 3

  • 9732 is the default port for P2P connections, can be overridden with --net-addr=ADDR:PORT when starting the node
  • 8732 is the default port for RPC connections, can be overridden with --rpc-addr=ADDR:PORT
  • All networking uses TCP.

If using iptables the below rules should suffice for tezos specifically.

Be aware you will need to allow other non tezos network services like DNS,NTP,DHCP depending on your configuration.

# Allow Tezos RPC
iptables -A INPUT -p tcp --dport 8732 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 8732 -m conntrack --ctstate ESTABLISHED -j ACCEPT

# Allow Tezos P2P connections
iptables -A INPUT -p tcp --dport 9732 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --dport 9732 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp --sport 9732 -m conntrack --ctstate ESTABLISHED -j ACCEPT
  • 3
    But closing unused ports won't safeguard a baker from a DDOS, will it? The standard way of doing that is to hide a baker (in private node config) behind a number of public nodes. Doing so means a baker can't be directly targeted and public nodes can be swapped out if there is an active DDOS.
    – latte_jed
    Commented Feb 1, 2019 at 8:37
  • 1
    You are correct, I guess the OP actually has 2 questions to be answered - one on DDOS and one on Tezos ports. The question ought to be split in two accordingly.
    – xtzbaker
    Commented Feb 2, 2019 at 6:39
  • When a node is in private mode, it is also possible to not allow incoming connections on port 9732 and to only allow related and established incoming connections. The private node will only establish connections to trusted nodes anyway and other, non-trusted nodes will not be able to connect.
    – cryptodad
    Commented Feb 4, 2019 at 18:58

@xtzbaker is spot on with the ports that the node uses. Preventing DDoS for the baking node is also one of the reasons that the most common setup for baking is to have a private baking node with trusted public nodes.

Basically, we have a single node that the baker and endorser uses and it's configured to be on private mode. Private mode will disallow connections from others and also tell its peers to not broadcast the node's existence to their peers. In order to truly keep our private node private, the private node's peers must be trusted to not reveal your private node's ip. This means your private node needs to set explicit peers to trusted nodes(as opposed to just let the node choose any available peers on the network).

What does it mean for a node to be trustworthy? Well, it varies from person to person depending on your accepted level of risk. But if you want to truly trust a node, the only way is to own them yourself. That said, many bakers accept the foundation public nodes to be trustworthy enough.

  • Thanks for the information about the setup. Can you explain how to do this set using docker images. I see that mainnet.sh file has all the default configurations but how to modify those configuration to have a setup as explained by you? There is not much information regarding setup done using docker images. Commented Feb 3, 2019 at 18:02
  • 1
    I currently wouldn't use docker for the baking private node, specifically reasons with using a ledger. But for frontend public nodes, using docker containers is much easier to maintain. The core dev team actively maintains them, at most only minutes behind latest on the mainnet branch. You could use the mainnet.sh, but I find running a custom docker-compose setup works better, this is what I use.
    – Frank
    Commented Feb 4, 2019 at 3:32

You could also add an extra layer of security by having your node's internet connection go through a DDoS protected VPN, like OctoVPN https://octovpn.com

  • Agree, I also think that the question was about protecting against DDOS and not so much the question of ports:
    – jdsika
    Commented Feb 4, 2019 at 12:58
  • cloudflare.com/ddos
    – jdsika
    Commented Feb 4, 2019 at 12:58

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.