-
Notifications
You must be signed in to change notification settings - Fork 49
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
NAT does not work for incoming connections. #14
Comments
Thank you for your detailed report. First of all, I see some duplicated rules here. Did you perhaps Here's my
Aside from the duplicated rules, the only differences seem to be:
Let me look into / think about why you could be missing those rules. I'm running 17.03.1-ce, maybe something has changed. Did you have the same issue with other hosts or versions, or is this your first time running ipv6nat? |
Also, after a flush + restart, can you send me the output of |
Duplicate rules reappear on container restart: root@host01:~# ip6tables -F
root@host01:~# ip6tables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain DOCKER (0 references)
target prot opt source destination
Chain DOCKER-ISOLATION (0 references)
target prot opt source destination
root@host01:~# docker restart ipv6nat
ipv6nat
root@host01:~# ip6tables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
DOCKER-ISOLATION all anywhere anywhere
DOCKER all anywhere anywhere
ACCEPT all anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT all anywhere anywhere
ACCEPT all anywhere anywhere
DOCKER all anywhere anywhere
ACCEPT all anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT all anywhere anywhere
ACCEPT all anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain DOCKER (2 references)
target prot opt source destination
Chain DOCKER-ISOLATION (1 references)
target prot opt source destination
DROP all anywhere anywhere
DROP all anywhere anywhere
RETURN all anywhere anywhere
(first time user, no experience with other docker versions) |
I just realised that's normal, they're for different interfaces. Send me the |
I've reset everything, removed all containers, networks, rebootet and recreated everything. root@host01:~# ip6tables-save
# Generated by ip6tables-save v1.4.21 on Fri Jul 21 12:44:09 2017
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [6:519]
:POSTROUTING ACCEPT [6:519]
:DOCKER - [0:0]
-A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
-A OUTPUT ! -d ::1/128 -m addrtype --dst-type LOCAL -j DOCKER
-A POSTROUTING -s fd00:dead:beef::/48 ! -o br-692577c71c23 -j MASQUERADE
-A DOCKER -i br-692577c71c23 -j RETURN
COMMIT
# Completed on Fri Jul 21 12:44:09 2017
# Generated by ip6tables-save v1.4.21 on Fri Jul 21 12:44:09 2017
*filter
:INPUT ACCEPT [43:16284]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [45:6368]
:DOCKER - [0:0]
:DOCKER-ISOLATION - [0:0]
-A FORWARD -j DOCKER-ISOLATION
-A FORWARD -o br-692577c71c23 -j DOCKER
-A FORWARD -o br-692577c71c23 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i br-692577c71c23 ! -o br-692577c71c23 -j ACCEPT
-A FORWARD -i br-692577c71c23 -o br-692577c71c23 -j ACCEPT
-A DOCKER-ISOLATION -j RETURN
COMMIT
# Completed on Fri Jul 21 12:44:09 2017 and: root@host01:~# ip6tables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
DOCKER-ISOLATION all anywhere anywhere
DOCKER all anywhere anywhere
ACCEPT all anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT all anywhere anywhere
ACCEPT all anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain DOCKER (1 references)
target prot opt source destination
Chain DOCKER-ISOLATION (1 references)
target prot opt source destination
RETURN all anywhere anywhere
|
In your container inspect I see various |
I've just linked |
Do you have the docker commands ( |
I'm using chef and this cookbook (connects to dockerd using the docker-api rubygem) so I cannot provide the commands right now, sorry. btw I tried running the |
OK, thanks. Probably something simple, not sure it's related to the docker version, but obviously it sets up ip6tables correctly, but then fails to detect the containers / exposed ports, so it creates no rules for those ports. I'll look into it and let you know. Would be nice to get to the bottom of this. Thanks for all the detailed info so far. |
Unfortunately I was not able to reproduce the problem by just creating the containers. What I did is the following:
(so basically the same as yours)
So here the 3 rules were created by ipv6nat for the exposed port: 2 in the So it seems the problem is not with Debian 8 or Docker 17.05.0-ce. Could you try the above docker commands on your machine (manually, without chef) to see if it works? Then we know it's somewhere in the way chef creates everything. |
Nevermind @moriz, I found it! Your container is started with Are you able to change this behaviour for your setup? I have considered changing ipv6nat so that |
I went ahead and changed this right away. This would make it easier for you and any other people running into this issue. Just upgrade to v0.3.0 and you should be good to go! (Closing this issue now, feel free to reopen or open a new one if you're still having issues) |
Thanks a lot! I didn't specify 0.0.0.0 myself but sadly https://github.com/chef-cookbooks/docker/blob/master/libraries/helpers_container.rb#L160 adds 0.0.0.0 :/ |
Yeah, that's what I figured. That's why I changed it in docker-ipv6nat, so you wouldn't have to change the cookbook. |
I was able to abuse the cookbook by using something like: port [
':80:8080',
':443:8443',
] which even works in the previous version of ipv6nat. Interestingly enough, [
{
"HostConfig": {
"PortBindings": {
"8080/tcp": [
{
"HostIp": "",
"HostPort": "80"
}
],
"8443/tcp": [
{
"HostIp": "",
"HostPort": "443"
}
]
}
},
"NetworkSettings": {
"Ports": {
"80/tcp": null,
"8080/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "80"
}
],
"8443/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "443"
}
]
}
}
}
] odd :/ Thanks a lot again, it works now like a charm :) |
Scenario
Debian 8
Docker version 17.05.0-ce, build 89658be
docker.service:
Steps
Privileged, IPv6 enabled, host net, module+ docker socket mounted:
(container appears after step 3)
As you can see the container is in the IPv6-enabed network. However the ports are not reachable.
ipv6tables -L
on the host:curl -6
requests to the nginx container still come through docker's IPv4 NAT:The text was updated successfully, but these errors were encountered: