diff --git a/networking/nat/src/main/java/tech/pegasys/teku/networking/nat/NatService.java b/networking/nat/src/main/java/tech/pegasys/teku/networking/nat/NatService.java index 3b0c124451c..3a78f984a28 100644 --- a/networking/nat/src/main/java/tech/pegasys/teku/networking/nat/NatService.java +++ b/networking/nat/src/main/java/tech/pegasys/teku/networking/nat/NatService.java @@ -13,7 +13,9 @@ package tech.pegasys.teku.networking.nat; +import java.util.HashSet; import java.util.Optional; +import java.util.Set; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.service.serviceutils.Service; @@ -59,8 +61,10 @@ protected SafeFuture doStart() { .start() .thenRun( () -> { - requestPortForward(natManager, p2pPort); - p2pPortIpv6.ifPresent(port -> requestPortForward(natManager, port)); + final Set p2pPorts = new HashSet<>(); + p2pPorts.add(p2pPort); + p2pPortIpv6.ifPresent(p2pPorts::add); + p2pPorts.forEach(port -> requestPortForward(natManager, port)); }); }