1

Server A and B have the same IP address with anycast. Server B connects to the origin server that is very close to server A and very far away from server B, since server A is closer, the response will be routed back to server A, isn't it possible to always route this type of requests back to server B, since server B initiated the connection to the origin server?

There was an answer to this question here:

https://networkengineering.stackexchange.com/a/33827/54705

You don't initiate a connection from an anycast address to any old address on the Internet. Anycast addresses are destination addresses. If a host with an anycast address needs to contact a different host on the Internet, it uses a non-anycast address, either with a secondary address on the interface, or, more likely, a different interface.

I'm asking if there is a protocol other than TCP which can send some flag or static route itself so the origin server knows which route to go back answering the anycast address?

You always have to send from a different IP address?

2

Packets are routed individually by destination IP address, regardless of any packets that have come before. A router does not maintain state (IP was specifically designed to be stateless), and routers route a packet based on the destination address, having no idea that it is in response to some other packet that went the other way.

TCP, and other transport protocols, play no part in the routing of packets. Transport protocols are the payload of IP packets, but routers only look at the IP packet header to route the packets. Routers do not go higher in the network stack to the transport protocol. That would slow routing, and it would require a lot of software to understand the various transport protocols, and updates for new transport protocols. IP neither knows nor cares what it is carrying in its payload.

| improve this answer | |
1

Server B connects to the origin server that is very close to server A and very far away from server B, since server A is closer, the response will be routed back to server A

That's not the way it works.

Anycast is used to shorten the route to global services: The same IP address is terminated in multiple locations and advertized over BGP. Now, clients across the globe accessing that IP get routed over the shortest route - to their nearest location. That way, anycast only works for connections that are initiated towards the anycast service.

Most likely, the server terminating the anycast IP uses normal, unicast IP addresses for its outbound connections (data exchange, administration, etc).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.