Score:0

How can I route traffic back through the interface it came through for Docker

gr flag

Currently I have a setup with 1 physical NIC with a public IP address, a standard docker environment and a GRE tunnel & bridge. If I run a container on a port, lets say 80, I'll be able to connect directly to the container via the public IP address.

However when attempting to connect via the GRE tunnel the traffic is routed back to the default route.

An attempted connection via the tunnel:

00:52:43.899400 tun0 In  IP {client_ip}.57122 > {tunnel_ip}.80: Flags [S], seq 1853400133, win 64240, options [mss 1400,nop,wscale 8,nop,nop,sackOK], length 0
00:52:43.899501 enp3s0f0 Out IP {tunnel_ip}.80 > {client_ip}.57122: Flags [S.], seq 3563157661, ack 1853400134, win 64240, options [mss 1460,nop,nop,sackOK,nop,wscale 7], length 0

And a successful connection via the public IP:

00:52:48.822480 enp3s0f0 In  IP {client_ip}.57112 > {public_ip}.80: Flags [P.], seq 3944436694:3944437201, ack 1907727361, win 1029, length 507
00:52:48.823843 enp3s0f0 Out IP {public_ip}.80 > {client_ip}.57112: Flags [P.], seq 1:109, ack 507, win 501, length 108

So my issue is that traffic is being routed from tunnel -> docker container -> public interface rather than returning to the tunnel. I've read multiple articles around the docker networking subject but couldn't find anything specific about this sort of issue. Any help appreciated.

Score:0
gr flag

You need to mark incoming packets (entering the the virtual nic), and then, setup routing rules based on the mark, and eventually a secondary routing table. Sometimes, source-based routing can also work.

See here: https://unix.stackexchange.com/questions/4420/reply-on-same-interface-as-incoming

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.