When running a socket server behind a network load balancer, with instances specified by IP, ...
server_sock = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM, proto=socket.IPPROTO_TCP)
server_sock.setblocking(False)
server_sock.bind(('', port))
server_sock.listen(socket.IPPROTO_TCP)
loop = asyncio.get_event_loop()
sock, adddress = await loop.sock_accept(server_sock)
... then...
print(adddress)
prints what appears to be a private IP of the network load balancer itself.
How can I determine the original client IP?
You can enable Proxy Protocol V2, and then write a function to parse the proxy protocol header [which gets sent ahead of incoming data]...
... which you you can use as, for example: