2

I have two NICs eno1 (ip: 12.34.56.78) and eno2 (44.55.66.77).

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:

-P INPUT DROP
0

1 Answer 1

1

1st Approach: specify the destination ip address

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

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

iptables -A INPUT -d 12.34.56.78 -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.