I am trying to conceptualise how networking works under the hood for linux VPNs which use TUN interfaces.
My current best guess is as follows (please correct me):
- Connection established to remote client/server.
- TUN interface created and brought up
- Routing table updated to set default gateway to the TUN interface
But wouldn't the packets destined for the remote client/server end up going into the TUN interface and forming a loop of sorts? How do VPN systems solve this? What is the gap in my understanding?