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.
9732is the default port for P2P connections, can be overridden with
--net-addr=ADDR:PORTwhen starting the node
8732is the default port for RPC connections, can be overridden with
- All networking uses TCP.
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
3But 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. Feb 1, 2019 at 8:37
1You 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.– xtzbakerFeb 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. 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. Feb 3, 2019 at 18:02
1I 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.– FrankFeb 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:– jdsikaFeb 4, 2019 at 12:58
cloudflare.com/ddos– jdsikaFeb 4, 2019 at 12:58