Skip to content

ELB client IP address

0

Dear Team - As per https://docs.aws.amazon.com/elasticloadbalancing/latest/network/edit-target-group-attributes.html,

TCP and TLS: By default, client IP preservation is disabled, and the source IP addresses provided to your applications are the private IP addresses of the load balancer nodes. To preserve the client's IP address, ensure that the target is located within the same VPC or a peered VPC and enable client IP preservation.** If you need the IP address of the client and these conditions are not met, enable the proxy protocol and get the client IP address from the proxy protocol header.**

we have below setup client from internet -> IGW -> NLB in VPC1 -> target in VPC2.

We also know which public IPs our client have and only wants to allow them. Is it possible through security group on our target?. with proxy protocol, we will get actual public IP address of client ? NLB was deployed without security group.

asked 2 years ago670 views

2 Answers
2
Accepted Answer

No.

The actual layer3 source IP of the traffic reaching the target will be the NLB ENI not the client, so you will not be able to block the traffic on your target using security group.

With proxy protocol the original client IP is sent at the beginning of the TCP payload.

But why not filter the traffic on the inbound rules of the security group attached to the NLB itself? the NLB does see the original client IP and it will be better to block the traffic earlier in the flow.

AWS
EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

AWS
EXPERT

reviewed 2 years ago

  • Thanks. As i mention, NLB was deployed with no SG and now, we don't see option to attach it. Might be some limitation. i am not 100% sure.

    But back to my original question. Is it possible for you to share some ref doc of what you stated about The actual layer3 source IP of the traffic reaching the target will be the NLB ENI not the client, so you will not be able to block the traffic on your target using security group. With proxy protocol the original client IP is sent at the beginning of the TCP payload.******

    1 - If We can not use SG to block the client IP on target SG, what's the use case of proxy protocol v2 ? Is it just to see client IP in application log ?

    2 - Do we have other option to achieve this ?

  • As mentioned in the other answer - you cannot associate a SG after the NLB was created.

    Are your NLB VPC and target VPC peered with VPC peering and are in the same region? if that is the case client IP can be preserved if you enable it and you do not need to use proxy protocol. so you will be able to use SG on your targets.

    If this is not the case then client IP cannot be preserved and you need to use proxy protocol instead. SG on the targets cannot be used since source IP will be the NLB. You need your application to be aware of proxy protocol to be able to parse it (see nginx documentation for example) and you will need to block/allow traffic on your server application.

  • above is valid for Instance and IP target both, right ?

  • Valid for IP target type only.

    Instance target type cannot be used when the NLB and the target are not within the same VPC. from the docs:

    When registering targets by instance ID, instances must be in the same Amazon VPC as the Network Load Balancer. You can't register instances by instance ID if they are in an VPC that is peered to the load balancer VPC (same Region or different Region). You can register these instances by IP address.

  • Thanks. I really appreciate your support

0

When using AWS Network Load Balancer (NLB), it's important to note a key limitation: Once you create an NLB without associating a security group, you cannot associate one later. For more details, check the AWS documentation here.

To allow Client IP traffic to the NLB SG association, you need to enable Client IP Preservation. This feature is required for associating security groups with the NLB. Instructions on how to enable this can be found here.

Alternatively, you can achieve similar results by configuring Network Access Control Lists (NACLs). This involves adding NACL rules to allow the client IP addresses into the subnets of your NLB. This method gives you an alternative to manage traffic control.

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.