So I have a few docker containers running and each of them configured to use a certain network interface for outgoing traffic.

Let's say for an example that there is a docker network called docker_1 , using interface eth1 and I have marked its outgoing traffic with 0x0c3f (--set-mark 0x0c3f).

Now, if eth1 is down the container will default to use eth0 instead for outgoing traffic, this is unwanted behavior. I would like for the container to never use eth0 even if eth1 is unavailable.

I have tried running:

iptables -t filter -I OUTPUT -p tcp -o eth0 -m mark --mark 0x0c3f -j REJECT

It does not work.

Does anyone have any idea of what is not working properly?



The problem is that you need to use the FORWARD - not output chain. Try changing "OUTPUT" to "FORWARD"

| 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.