I have two NICs eno1 (ip: and eno2 (

I also have a service on a specific port (lets say 8888) running.

I want to allow traffic over eno1 to that service, but want to drop any packet to that port over eno2.

I tried it with the following iptables rule:

iptables -A INPUT -i eno2 -p tcp --dport 8888 -j DROP

Also with this (some of my rules have this strange garbage keyword in it):

iptables -A INPUT -i eno2 -p tcp -m tcp --dport 8888 -j garbage

But still the service is available over both NICs and their corresponding ips.

Please enlighten me about this.

The service is running as a docker container.

EDITs for comments:

iptables -S contains:


1 Answer 1


1st Approach: specify the destination ip address

Iptables -I INPUT 1 -p tcp --dport 8888 -d -j DROP

2nd Approach: blocking all trafic except that one designated to ip address from 1st NIC

iptables -A INPUT -d -p tcp --dport 8888 -j ACCEPT
iptables -A INPUT -p tcp --dport 8888 -j DROP

Explanation: As long as the traffic is designated to that particular ip addres, doesn't matter what is the interface from which is comming from.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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