-
Notifications
You must be signed in to change notification settings - Fork 18.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't use ip_forward to expose containers to the public internet #11508
Comments
The problem with that idea is that it results in the docker proxy being used for this traffic. The docker proxy has a very long and troubling history. But bugs aside, with a proxy, the applications running inside lose a lot of functionality having to go through a proxy (tcp only, client addr hidden, QoS flags stripped, etc). The container would also be unable to reach the public internet. However there is indeed a concern here. Because docker turns IP forwarding on without adding any apropriate filter rules to the Thus I think an appropriate action here would be for docker to change the default policy on the |
I`m trying as well to expose a container port to the host ip , is there any other solution t then the iptables one to expose a container port to hosts ip ? |
@dexterddit I'm working on a solution based on @phemmer's suggestion. @phemmer I'm actually seeing two cases here:
I think you suggestion for dropping unmatched forward packets is good for case 1. For case 2 I think some else is needed. Like a hook that is passed the proposed rules so the can be injected in the right place. |
So these rules seem to work reliably:
When containers are added and removed, docker inserts rules at the beginning of the They also seem to survive restarting docker. So @phemmer, can we make these rules automated in docker itself? |
Please, feel free to open a PR with the suggested change for discussion. I'm sure this will get more 👀 as soon as it's on code 😄 |
When will this issue be addressed, @thaJeztah @jfrazelle? |
If the goal is to disable ip forwarding inside container, the container can be started as follows: This makes it some what compliant with CIS rules for disabling ip forwarding, since a container is started without it. The host still has ip forwarding. |
What is CIS? We wanted IP forwarding off on the host, tho turning it off in containers is interesting. |
I believe this should be closed by #28257, which sets the forward policy to DROP. |
Yes you're right, I think this can be closed |
sorry to ask this on a closed thread, but do we still need to enable ip_forward in a normal linux installation? what are the recommendations ? (I totally get that docker#28257 fixes ip_tables to make docker more secure) |
Setting
net.ipv4.ip_forward=1
is troublesome for various reasons, including security.Would it be possible to stop using that and instead use something like
iptables
rule below instead?Example for container started with
--port 0.0.0.0:29418:29418
This should work, though translating
0.0.0.0
toeth0
is a potential problem. I'm not aniptables
wizard, so there is certainly a better way to do this.The text was updated successfully, but these errors were encountered: