# NetworkLoadBalancerProps

Properties for a network load balancer.

Extends: [BaseLoadBalancerProps](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.BaseLoadBalancerProps.html)
Used as props by: [NetworkLoadBalancer](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.NetworkLoadBalancer.html)

- Source: [`aws-elasticloadbalancingv2/lib/nlb/network-load-balancer.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-elasticloadbalancingv2/lib/nlb/network-load-balancer.ts#L43)
- Type last changed: v2.222.0 · 4 Nov 2025

## Example

TypeScript:

```ts
declare const vpc: ec2.Vpc;

const lb = new elbv2.NetworkLoadBalancer(this, 'LB', {
  vpc,
  ipAddressType: elbv2.IpAddressType.DUAL_STACK,
  enablePrefixForIpv6SourceNat: true,
});

const listener = lb.addListener('Listener', {
  port: 1229,
  protocol: elbv2.Protocol.UDP,
});
```

Python:

```python
# vpc: ec2.Vpc

lb = elbv2.NetworkLoadBalancer(self, "LB",
    vpc=vpc,
    ip_address_type=elbv2.IpAddressType.DUAL_STACK,
    enable_prefix_for_ipv6_source_nat=True
)

listener = lb.add_listener("Listener",
    port=1229,
    protocol=elbv2.Protocol.UDP
)
```

Java:

```java
Vpc vpc;

NetworkLoadBalancer lb = NetworkLoadBalancer.Builder.create(this, "LB")
        .vpc(vpc)
        .ipAddressType(IpAddressType.DUAL_STACK)
        .enablePrefixForIpv6SourceNat(true)
        .build();

NetworkListener listener = lb.addListener("Listener", BaseNetworkListenerProps.builder()
        .port(1229)
        .protocol(Protocol.UDP)
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
Vpc vpc;

var lb = new NetworkLoadBalancer(this, "LB", new NetworkLoadBalancerProps {
    Vpc = vpc,
    IpAddressType = IpAddressType.DUAL_STACK,
    EnablePrefixForIpv6SourceNat = true
});

var listener = lb.AddListener("Listener", new BaseNetworkListenerProps {
    Port = 1229,
    Protocol = Protocol.UDP
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var vpc Vpc

lb := elbv2.NewNetworkLoadBalancer(this, jsii.String("LB"), &NetworkLoadBalancerProps{
	Vpc: Vpc,
	IpAddressType: elbv2.IpAddressType_DUAL_STACK,
	EnablePrefixForIpv6SourceNat: jsii.Boolean(true),
})

listener := lb.AddListener(jsii.String("Listener"), &BaseNetworkListenerProps{
	Port: jsii.Number(1229),
	Protocol: elbv2.Protocol_UDP,
})
```

## Properties

- `clientRoutingPolicy`: [ClientRoutingPolicy](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.ClientRoutingPolicy.html) — The AZ affinity routing policy.

  **Default:** AZ affinity is disabled.

- `crossZoneEnabled`: boolean — Indicates whether cross-zone load balancing is enabled.

  **Default:** false for Network Load Balancers and true for Application Load Balancers. This can not be `false` for Application Load Balancers.

- `deletionProtection`: boolean = false — Indicates whether deletion protection is enabled.

- `denyAllIgwTraffic`: boolean — Indicates whether the load balancer blocks traffic through the Internet Gateway (IGW).

  **Default:** false for internet-facing load balancers and true for internal load balancers

- `disableSecurityGroups`: boolean = false — Create a Network Load Balancer without security groups.

  When true, creates an NLB that cannot have security groups attached.
  This is useful when you need to create a traditional NLB without security group associations.

  This property only takes effect when the feature flag
  `@aws-cdk/aws-elasticloadbalancingv2:networkLoadBalancerWithSecurityGroupByDefault` is enabled.

- `enablePrefixForIpv6SourceNat`: boolean — Indicates whether to use an IPv6 prefix from each subnet for source NAT.

  **Default:** undefined - NLB default behavior is false

  The IP address type must be IpAddressType.DUALSTACK.

- `enforceSecurityGroupInboundRulesOnPrivateLinkTraffic`: boolean = true — Indicates whether to evaluate inbound security group rules for traffic sent to a Network Load Balancer through AWS PrivateLink.

- `internetFacing`: boolean = false — Whether the load balancer has an internet-routable address.

- `ipAddressType`: [IpAddressType](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.IpAddressType.html) = IpAddressType.IPV4 — The type of IP addresses to use.

  If you want to add a UDP or TCP_UDP listener to the load balancer,
  you must choose IPv4.

- `loadBalancerName`: string — Name of the load balancer.

  **Default:** Automatically generated name.

- `minimumCapacityUnit`: number — The minimum capacity (LCU) for a load balancer.

  **Default:** undefined - ELB default is 0 LCU

- `securityGroups`: [ISecurityGroup](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.ISecurityGroup.html)[] — Security groups to associate with this load balancer.

  **Default:** No security groups associated with the load balancer.

- `subnetMappings`: [SubnetMapping](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticloadbalancingv2.SubnetMapping.html)[] — Subnet information for the load balancer.

  **Default:** undefined - The VPC default strategy for subnets is used

- `vpc`: [IVpc](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.IVpc.html) (required) — The VPC network to place the load balancer in.

- `vpcSubnets`: [SubnetSelection](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.SubnetSelection.html) — Which subnets place the load balancer in.

  **Default:** the Vpc default strategy.

- `zonalShift`: boolean = false — Indicates whether zonal shift is enabled.
