Answer the question
In order to leave comments, you need to log in
Why is iptables not closing a port?
Good day. I try to close the iptables port from outside, but the rule does not work.
I have a service on port 81, in docker. I want the port to be closed through the external interface (except for one IP), I will go through Localhost
What I do - I
allow access to the port from my IP
iptables -A INPUT -s 188.242.111.111 -p tcp --dport 81 -j ACCEPT I
prohibit access to this port to external interface
iptables -A INPUT -i enp2s0 -p tcp --dport 81 -j DROP
output iptables -L -n -v
Answer the question
In order to leave comments, you need to log in
Docker has its own tables, and you edit the main ones. See real life withiptables-save
So just don't expose the service port to the outside in your docker-compose file:
ports:
- "81"
If so?
iptables -t nat -A PREROUTING -s 188.242.111.111 -p tcp --dport 81 -j ACCEPT
iptables -t nat -A PREROUTING -i enp2s0 -p tcp --dport 81 -j DROP
iptables -nvL -t nat
Little information, do you have internet on enp2s0 or some pppoe, tun?
look at iptables-save and ip add.
On counters 0 and on ACCEPT and on DROP
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question