Skip to content
This repository has been archived by the owner on Dec 5, 2017. It is now read-only.

cannot connect to Docker-exposed port of same host in elastic Mesos (e.g. GCE, digitalocean, ...) #94

Closed
3 tasks done
jdef opened this issue Dec 2, 2014 · 15 comments
Closed
3 tasks done
Milestone

Comments

@jdef
Copy link

jdef commented Dec 2, 2014

[[EDIT]]
How I got here:

  1. start up the guestbook example
  2. ssh to a slave node to interact with the frontend controller
  3. curl http://${this_slaves_local_ip_address}:31030/index.php
  4. observe timeout failure
  5. curl http://${other_slave_local_ip_address}:31030/index.php
  6. observe that it works, quickly

Need to reproduce elsewhere...

  • iptables should be resolved on GCE -- COMFIRMED
  • iptables should be resolved on DO
  • does iptables problem exist on EC2?? (EC2 is apparently not supported, undergoing major revision)
@jdef jdef added the class/bug label Dec 2, 2014
@jdef
Copy link
Author

jdef commented Dec 2, 2014

Firewall configuration on the GCE slave:

jclouds@development-2451-650:~$ sudo iptables-save
# Generated by iptables-save v1.4.14 on Tue Dec  2 21:53:25 2014
*nat
:PREROUTING ACCEPT [3962:236852]
:INPUT ACCEPT [3635:217232]
:OUTPUT ACCEPT [594:39206]
:POSTROUTING ACCEPT [605:39866]
:DOCKER - [0:0]
-A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
-A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER
-A POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE
-A DOCKER ! -i docker0 -p tcp -m tcp --dport 31020 -j DNAT --to-destination 172.17.0.2:6379
-A DOCKER ! -i docker0 -p tcp -m tcp --dport 31030 -j DNAT --to-destination 172.17.0.4:80
COMMIT
# Completed on Tue Dec  2 21:53:25 2014
# Generated by iptables-save v1.4.14 on Tue Dec  2 21:53:25 2014
*filter
:INPUT DROP [488:29280]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [150:10397]
-A INPUT -s 10.181.4.180/32 -j ACCEPT
-A INPUT -s 10.99.68.149/32 -j ACCEPT
-A INPUT -s 10.158.11.199/32 -j ACCEPT
-A INPUT -s 10.134.57.34/32 -j ACCEPT
-A INPUT -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m state --state NEW,ESTABLISHED -m tcp --dport 22 -j ACCEPT
-A INPUT -i eth0 -p udp -m udp --dport 1194 -j ACCEPT
-A INPUT -i tun0 -j ACCEPT
-A INPUT -i lo -m comment --comment "Allow loopback" -j ACCEPT
-A INPUT -p icmp -m comment --comment "Allow ping" -j ACCEPT
-A FORWARD -d 172.17.0.4/32 ! -i docker0 -o docker0 -p tcp -m tcp --dport 80 -j ACCEPT
-A FORWARD -d 172.17.0.2/32 ! -i docker0 -o docker0 -p tcp -m tcp --dport 6379 -j ACCEPT
-A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i docker0 ! -o docker0 -j ACCEPT
-A FORWARD -i docker0 -o docker0 -j ACCEPT
-A OUTPUT -o eth0 -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
COMMIT
# Completed on Tue Dec  2 21:53:25 2014

@jdef
Copy link
Author

jdef commented Dec 2, 2014

Docker info:

jclouds@development-2451-650:~$ sudo docker ps
CONTAINER ID        IMAGE                     COMMAND                CREATED             STATUS              PORTS                     NAMES
4076df02c732        jdef/php-redis:latest     "/bin/sh -c /run.sh"   About an hour ago   Up About an hour                              k8s_php-redis.5fa73094_e8f87f0f-7a65-11e4-8b8c-42010a863922.mesos_e8f87f0f-7a65-11e4-8b8c-42010a863922_74bd198e
0bdd86a7ea56        kubernetes/pause:go       "/pause"               About an hour ago   Up About an hour    0.0.0.0:31030->80/tcp     k8s_net.62283c5_e8f87f0f-7a65-11e4-8b8c-42010a863922.mesos_e8f87f0f-7a65-11e4-8b8c-42010a863922_bd597ef8
32d5b8586ff1        jdef/redis-slave:latest   "/bin/sh -c /run.sh"   About an hour ago   Up About an hour                              k8s_slave.a9a11e43_bda7385a-7a61-11e4-8b8c-42010a863922.mesos_bda7385a-7a61-11e4-8b8c-42010a863922_81074f7d
6fc1da2e00a3        kubernetes/pause:go       "/pause"               About an hour ago   Up About an hour    0.0.0.0:31020->6379/tcp   k8s_net.d8aa8435_bda7385a-7a61-11e4-8b8c-42010a863922.mesos_bda7385a-7a61-11e4-8b8c-42010a863922_985a37f3
jclouds@development-2451-650:~$ sudo docker version
Client version: 1.3.2
Client API version: 1.15
Go version (client): go1.3.3
Git commit (client): 39fa2fa
OS/Arch (client): linux/amd64
Server version: 1.3.2
Server API version: 1.15
Go version (server): go1.3.3
Git commit (server): 39fa2fa

@jdef
Copy link
Author

jdef commented Dec 2, 2014

Docker processes:

jclouds@development-2451-650:~$ ps auxwww|grep -e docker|grep -v -e grep
root      2027  1.9  0.3 1158420 23536 ?       Sl   19:59   2:29 /usr/bin/docker -d -p /var/run/docker.pid
root      2383  2.2  0.7 389748 57108 ?        Sl   19:59   2:50 /usr/local/sbin/mesos-slave --master=zk://10.134.57.34:2181/mesos --log_dir=/var/log/mesos --containerizers=docker,mesos --executor_registration_timeout=5mins --hostname=10.181.4.180 --ip=10.181.4.180 --attributes=host:development-2451-650.c.k8s-mesos.internal
root      3343  0.0  0.1 247444 11332 ?        Sl   20:28   0:00 docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 31020 -container-ip 172.17.0.2 -container-port 6379
root      4505  0.0  0.1 198428 11540 ?        Sl   20:58   0:00 docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 31030 -container-ip 172.17.0.4 -container-port 80

@jdef jdef changed the title cannot connect to Docker-exposed port of same host in elastic GCE/Mesos cannot connect to Docker-exposed port of same host in elastic Mesos (e.g. GCE, digitalocean, ...) Dec 3, 2014
@jdef
Copy link
Author

jdef commented Dec 3, 2014

xref: moby/moby#6810

For some reason this was reverted after it was merged to master:

@jdef
Copy link
Author

jdef commented Dec 3, 2014

This breaks the actual usability of the guestbook. While all the containers are, in fact running, and the HTTP server will happily serve up a web page - it does NOT actually connect to redis, and instead times out.

@ConnorDoyle
Copy link

cc @cmaloney for more ideas on this.

@jdef
Copy link
Author

jdef commented Dec 3, 2014

Playing around with a docker-1.3.1-dev build that has the hairpin change installed. Also had to add some iptables rules to get connectivity to work from within the frontendController container to the $SERVICE_HOST IP address. Also had to use the jdef/php-redis image to pick up the correct env variables.

:; iptables -A INPUT -i eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
:; iptables -A INPUT -p tcp -m state --state NEW,ESTABLISHED -m tcp --dport 10000 -j ACCEPT
:; iptables -A OUTPUT -o eth1 -j ACCEPT
:; iptables -A OUTPUT -p tcp -m tcp --sport 10000 -m state --state ESTABLISHED -j ACCEPT

redis-cli (executed from within the frontendController) is still experiencing Connection Reset errors. tcpdump looks like this:

01:57:09.291403 IP (tos 0x0, ttl 64, id 6664, offset 0, flags [DF], proto TCP (6), length 60)
    172.17.0.3.56679 > 10.132.189.240.10000: Flags [S], cksum 0x0a6d (correct), seq 2233759172, win 14600, options [mss 1460,sackOK,TS val 550793164 ecr 0,nop,wscale 8], length 0
        0x0000:  f6a2 08a9 26ff 0242 ac11 0003 0800 4500  ....&..B......E.
        0x0010:  003c 1a08 4000 4006 ac2b ac11 0003 0a84  .<..@.@..+......
        0x0020:  bdf0 dd67 2710 8524 75c4 0000 0000 a002  ...g'..$u.......
        0x0030:  3908 0a6d 0000 0204 05b4 0402 080a 20d4  9..m............
        0x0040:  6fcc 0000 0000 0103 0308                 o.........
01:57:09.291520 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 60)
    10.132.189.240.10000 > 172.17.0.3.56679: Flags [S.], cksum 0x74b7 (incorrect -> 0x5eff), seq 249564244, ack 2233759173, win 14480, options [mss 1460,sackOK,TS val 550793164 ecr 550793164,nop,wscale 8], length 0
        0x0000:  0242 ac11 0003 f6a2 08a9 26ff 0800 4500  .B........&...E.
        0x0010:  003c 0000 4000 4006 c633 0a84 bdf0 ac11  .<..@.@..3......
        0x0020:  0003 2710 dd67 0ee0 0c54 8524 75c5 a012  ..'..g...T.$u...
01:57:05.428801 IP (tos 0x0, ttl 64, id 2076, offset 0, flags [DF], proto TCP (6), length 60)
    172.17.0.3.56678 > 10.132.189.240.10000: Flags [S], cksum 0x041f (correct), seq 2699125787, win 14600, options [mss 1460,sackOK,TS val 550792199 ecr 0,nop,wscale 8], length 0
        0x0000:  f6a2 08a9 26ff 0242 ac11 0003 0800 4500  ....&..B......E.
        0x0010:  003c 081c 4000 4006 be17 ac11 0003 0a84  .<..@.@.........
        0x0020:  bdf0 dd66 2710 a0e1 641b 0000 0000 a002  ...f'...d.......
        0x0030:  3908 041f 0000 0204 05b4 0402 080a 20d4  9...............
        0x0040:  6c07 0000 0000 0103 0308                 l.........
01:57:05.428845 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 60)
    10.132.189.240.10000 > 172.17.0.3.56678: Flags [S.], cksum 0x74b7 (incorrect -> 0x60b0), seq 2339539847, ack 2699125788, win 14480, options [mss 1460,sackOK,TS val 550792199 ecr 550792199,nop,wscale 8], length 0
        0x0000:  0242 ac11 0003 f6a2 08a9 26ff 0800 4500  .B........&...E.
        0x0010:  003c 0000 4000 4006 c633 0a84 bdf0 ac11  .<..@.@..3......
        0x0020:  0003 2710 dd66 8b72 8b87 a0e1 641c a012  ..'..f.r....d...
        0x0030:  3890 74b7 0000 0204 05b4 0402 080a 20d4  8.t.............
        0x0040:  6c07 20d4 6c07 0103 0308                 l...l.....
01:57:05.428879 IP (tos 0x0, ttl 64, id 2077, offset 0, flags [DF], proto TCP (6), length 52)
    172.17.0.3.56678 > 10.132.189.240.10000: Flags [.], cksum 0xc7d3 (correct), seq 1, ack 1, win 58, options [nop,nop,TS val 550792199 ecr 550792199], length 0
        0x0000:  f6a2 08a9 26ff 0242 ac11 0003 0800 4500  ....&..B......E.
        0x0010:  0034 081d 4000 4006 be1e ac11 0003 0a84  .4..@.@.........
        0x0020:  bdf0 dd66 2710 a0e1 641c 8b72 8b88 8010  ...f'...d..r....
        0x0030:  003a c7d3 0000 0101 080a 20d4 6c07 20d4  .:..........l...
        0x0040:  6c07                                     l.
01:57:05.429326 IP (tos 0x0, ttl 64, id 59279, offset 0, flags [DF], proto TCP (6), length 52)
    10.132.189.240.10000 > 172.17.0.3.56678: Flags [F.], cksum 0x74af (incorrect -> 0xc7d3), seq 1, ack 1, win 57, options [nop,nop,TS val 550792199 ecr 550792199], length 0
        0x0000:  0242 ac11 0003 f6a2 08a9 26ff 0800 4500  .B........&...E.
        0x0010:  0034 e78f 4000 4006 deab 0a84 bdf0 ac11  .4..@.@.........
        0x0020:  0003 2710 dd66 8b72 8b88 a0e1 641c 8011  ..'..f.r....d...
        0x0030:  0039 74af 0000 0101 080a 20d4 6c07 20d4  .9t.........l...
        0x0040:  6c07                                     l.
01:57:05.432037 IP (tos 0x0, ttl 64, id 2078, offset 0, flags [DF], proto TCP (6), length 52)
    172.17.0.3.56678 > 10.132.189.240.10000: Flags [.], cksum 0xc7d1 (correct), seq 1, ack 2, win 58, options [nop,nop,TS val 550792200 ecr 550792199], length 0
        0x0000:  f6a2 08a9 26ff 0242 ac11 0003 0800 4500  ....&..B......E.
        0x0010:  0034 081e 4000 4006 be1d ac11 0003 0a84  .4..@.@.........
        0x0020:  bdf0 dd66 2710 a0e1 641c 8b72 8b89 8010  ...f'...d..r....
        0x0030:  003a c7d1 0000 0101 080a 20d4 6c08 20d4  .:..........l...
        0x0040:  6c07                                     l.
01:57:09.291113 IP (tos 0x0, ttl 64, id 2079, offset 0, flags [DF], proto TCP (6), length 80)
    172.17.0.3.56678 > 10.132.189.240.10000: Flags [P.], cksum 0x967f (correct), seq 1:29, ack 2, win 58, options [nop,nop,TS val 550793164 ecr 550792199], length 28
        0x0000:  f6a2 08a9 26ff 0242 ac11 0003 0800 4500  ....&..B......E.
        0x0010:  0050 081f 4000 4006 be00 ac11 0003 0a84  .P..@.@.........
        0x0020:  bdf0 dd66 2710 a0e1 641c 8b72 8b89 8018  ...f'...d..r....
        0x0030:  003a 967f 0000 0101 080a 20d4 6fcc 20d4  .:..........o...
        0x0040:  6c07 2a32 0d0a 2434 0d0a 6475 6d70 0d0a  l.*2..$4..dump..
        0x0050:  2438 0d0a 6d65 7373 6167 6573 0d0a       $8..messages..
01:57:09.291151 IP (tos 0x0, ttl 64, id 58891, offset 0, flags [DF], proto TCP (6), length 40)
    10.132.189.240.10000 > 172.17.0.3.56678: Flags [R], cksum 0x1fe5 (correct), seq 2339539849, win 0, length 0
        0x0000:  0242 ac11 0003 f6a2 08a9 26ff 0800 4500  .B........&...E.
        0x0010:  0028 e60b 4000 4006 e03b 0a84 bdf0 ac11  .(..@.@..;......
        0x0020:  0003 2710 dd66 8b72 8b89 0000 0000 5004  ..'..f.r......P.
        0x0030:  0000 1fe5 0000                           ......
01:57:09.291403 IP (tos 0x0, ttl 64, id 6664, offset 0, flags [DF], proto TCP (6), length 60)
    172.17.0.3.56679 > 10.132.189.240.10000: Flags [S], cksum 0x0a6d (correct), seq 2233759172, win 14600, options [mss 1460,sackOK,TS val 550793164 ecr 0,nop,wscale 8], length 0
        0x0000:  f6a2 08a9 26ff 0242 ac11 0003 0800 4500  ....&..B......E.
        0x0010:  003c 1a08 4000 4006 ac2b ac11 0003 0a84  .<..@.@..+......
        0x0020:  bdf0 dd67 2710 8524 75c4 0000 0000 a002  ...g'..$u.......
        0x0030:  3908 0a6d 0000 0204 05b4 0402 080a 20d4  9..m............
        0x0040:  6fcc 0000 0000 0103 0308                 o.........
01:57:09.291520 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 60)
    10.132.189.240.10000 > 172.17.0.3.56679: Flags [S.], cksum 0x74b7 (incorrect -> 0x5eff), seq 249564244, ack 2233759173, win 14480, options [mss 1460,sackOK,TS val 550793164 ecr 550793164,nop,wscale 8], length 0
        0x0000:  0242 ac11 0003 f6a2 08a9 26ff 0800 4500  .B........&...E.
        0x0010:  003c 0000 4000 4006 c633 0a84 bdf0 ac11  .<..@.@..3......
        0x0020:  0003 2710 dd67 0ee0 0c54 8524 75c5 a012  ..'..g...T.$u...
01:57:05.428801 IP (tos 0x0, ttl 64, id 2076, offset 0, flags [DF], proto TCP (6), length 60)
    172.17.0.3.56678 > 10.132.189.240.10000: Flags [S], cksum 0x041f (correct), seq 2699125787, win 14600, options [mss 1460,sackOK,TS val 550792199 ecr 0,nop,wscale 8], length 0
        0x0000:  f6a2 08a9 26ff 0242 ac11 0003 0800 4500  ....&..B......E.
        0x0010:  003c 081c 4000 4006 be17 ac11 0003 0a84  .<..@.@.........
        0x0020:  bdf0 dd66 2710 a0e1 641b 0000 0000 a002  ...f'...d.......
        0x0030:  3908 041f 0000 0204 05b4 0402 080a 20d4  9...............
        0x0040:  6c07 0000 0000 0103 0308                 l.........
01:57:05.428845 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 60)
    10.132.189.240.10000 > 172.17.0.3.56678: Flags [S.], cksum 0x74b7 (incorrect -> 0x60b0), seq 2339539847, ack 2699125788, win 14480, options [mss 1460,sackOK,TS val 550792199 ecr 550792199,nop,wscale 8], length 0
        0x0000:  0242 ac11 0003 f6a2 08a9 26ff 0800 4500  .B........&...E.
        0x0010:  003c 0000 4000 4006 c633 0a84 bdf0 ac11  .<..@.@..3......
        0x0020:  0003 2710 dd66 8b72 8b87 a0e1 641c a012  ..'..f.r....d...
        0x0030:  3890 74b7 0000 0204 05b4 0402 080a 20d4  8.t.............
        0x0040:  6c07 20d4 6c07 0103 0308                 l...l.....
01:57:05.428879 IP (tos 0x0, ttl 64, id 2077, offset 0, flags [DF], proto TCP (6), length 52)
    172.17.0.3.56678 > 10.132.189.240.10000: Flags [.], cksum 0xc7d3 (correct), seq 1, ack 1, win 58, options [nop,nop,TS val 550792199 ecr 550792199], length 0
        0x0000:  f6a2 08a9 26ff 0242 ac11 0003 0800 4500  ....&..B......E.
        0x0010:  0034 081d 4000 4006 be1e ac11 0003 0a84  .4..@.@.........
        0x0020:  bdf0 dd66 2710 a0e1 641c 8b72 8b88 8010  ...f'...d..r....
        0x0030:  003a c7d3 0000 0101 080a 20d4 6c07 20d4  .:..........l...
...
...
...
01:57:09.291644 IP (tos 0x0, ttl 64, id 6666, offset 0, flags [DF], proto TCP (6), length 80)
    172.17.0.3.56679 > 10.132.189.240.10000: Flags [P.], cksum 0x9894 (correct), seq 1:29, ack 1, win 58, options [nop,nop,TS val 550793164 ecr 550793164], length 28
        0x0000:  f6a2 08a9 26ff 0242 ac11 0003 0800 4500  ....&..B......E.
        0x0010:  0050 1a0a 4000 4006 ac15 ac11 0003 0a84  .P..@.@.........
        0x0020:  bdf0 dd67 2710 8524 75c5 0ee0 0c55 8018  ...g'..$u....U..
        0x0030:  003a 9894 0000 0101 080a 20d4 6fcc 20d4  .:..........o...
        0x0040:  6fcc 2a32 0d0a 2434 0d0a 6475 6d70 0d0a  o.*2..$4..dump..
        0x0050:  2438 0d0a 6d65 7373 6167 6573 0d0a       $8..messages..
01:57:09.291660 IP (tos 0x0, ttl 64, id 25497, offset 0, flags [DF], proto TCP (6), length 52)
    10.132.189.240.10000 > 172.17.0.3.56679: Flags [.], cksum 0x74af (incorrect -> 0xc607), seq 1, ack 29, win 57, options [nop,nop,TS val 550793164 ecr 550793164], length 0
        0x0000:  0242 ac11 0003 f6a2 08a9 26ff 0800 4500  .B........&...E.
        0x0010:  0034 6399 4000 4006 62a2 0a84 bdf0 ac11  .4c.@.@.b.......
        0x0020:  0003 2710 dd67 0ee0 0c55 8524 75e1 8010  ..'..g...U.$u...
        0x0030:  0039 74af 0000 0101 080a 20d4 6fcc 20d4  .9t.........o...
        0x0040:  6fcc                                     o.
01:57:09.292610 IP (tos 0x0, ttl 64, id 25498, offset 0, flags [DF], proto TCP (6), length 52)
    10.132.189.240.10000 > 172.17.0.3.56679: Flags [R.], cksum 0x74af (incorrect -> 0xc602), seq 1, ack 29, win 57, options [nop,nop,TS val 550793165 ecr 550793164], length 0
        0x0000:  0242 ac11 0003 f6a2 08a9 26ff 0800 4500  .B........&...E.
        0x0010:  0034 639a 4000 4006 62a1 0a84 bdf0 ac11  .4c.@.@.b.......
        0x0020:  0003 2710 dd67 0ee0 0c55 8524 75e1 8014  ..'..g...U.$u...
        0x0030:  0039 74af 0000 0101 080a 20d4 6fcd 20d4  .9t.........o...
        0x0040:  6fcc

current iptables:

root@development-1823-93f:~/docker# iptables-save
# Generated by iptables-save v1.4.14 on Wed Dec  3 02:03:57 2014
*nat
:PREROUTING ACCEPT [316:18473]
:INPUT ACCEPT [265:15904]
:OUTPUT ACCEPT [110:7164]
:POSTROUTING ACCEPT [119:7704]
:DOCKER - [0:0]
-A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER
-A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER
-A POSTROUTING -s 172.17.0.3/32 -d 172.17.0.3/32 -p tcp -m tcp --dport 80 -j MASQUERADE
-A POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE
-A DOCKER -p tcp -m tcp --dport 31030 -j DNAT --to-destination 172.17.0.3:80
COMMIT
# Completed on Wed Dec  3 02:03:57 2014
# Generated by iptables-save v1.4.14 on Wed Dec  3 02:03:57 2014
*filter
:INPUT DROP [27:1263]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -s 10.132.189.240/32 -j ACCEPT
-A INPUT -s 10.132.189.243/32 -j ACCEPT
-A INPUT -s 10.132.189.242/32 -j ACCEPT
-A INPUT -s 10.132.189.241/32 -j ACCEPT
-A INPUT -i eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m state --state NEW,ESTABLISHED -m tcp --dport 22 -j ACCEPT
-A INPUT -i eth0 -p udp -m udp --dport 1194 -j ACCEPT
-A INPUT -i tun0 -j ACCEPT
-A INPUT -i lo -m comment --comment "Allow loopback" -j ACCEPT
-A INPUT -p icmp -m comment --comment "Allow ping" -j ACCEPT
-A INPUT -i eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m state --state NEW,ESTABLISHED -m tcp --dport 31030 -j ACCEPT
-A INPUT -p tcp -m state --state NEW,ESTABLISHED -m tcp --dport 10000 -j ACCEPT
-A INPUT -p tcp -m state --state NEW,ESTABLISHED -m tcp --dport 10001 -j ACCEPT
-A FORWARD -d 172.17.0.3/32 ! -i docker0 -o docker0 -p tcp -m tcp --dport 80 -j ACCEPT
-A FORWARD -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i docker0 ! -o docker0 -j ACCEPT
-A FORWARD -i docker0 -o docker0 -j ACCEPT
-A OUTPUT -o eth0 -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 22 -m state --state ESTABLISHED -j ACCEPT
-A OUTPUT -o eth1 -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 31030 -m state --state ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 10000 -m state --state ESTABLISHED -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 10001 -m state --state ESTABLISHED -j ACCEPT
COMMIT
# Completed on Wed Dec  3 02:03:57 2014

@jdef
Copy link
Author

jdef commented Dec 3, 2014

FWIW, my browser currently returns this:

<br />
<b>Fatal error</b>:  Uncaught exception 'Predis\Connection\ConnectionException' with message 'Error while reading line from the server [tcp://10.132.189.240:10000]' in /vendor/predis/predis/lib/Predis/Connection/AbstractConnection.php:141
Stack trace:
#0 /vendor/predis/predis/lib/Predis/Connection/StreamConnection.php(208): Predis\Connection\AbstractConnection-&gt;onConnectionError('Error while rea...')
#1 /vendor/predis/predis/lib/Predis/Connection/AbstractConnection.php(130): Predis\Connection\StreamConnection-&gt;read()
#2 /vendor/predis/predis/lib/Predis/Connection/AbstractConnection.php(122): Predis\Connection\AbstractConnection-&gt;readResponse(Object(Predis\Command\StringGet))
#3 /vendor/predis/predis/lib/Predis/Client.php(246): Predis\Connection\AbstractConnection-&gt;executeCommand(Object(Predis\Command\StringGet))
#4 /vendor/predis/predis/lib/Predis/Client.php(228): Predis\Client-&gt;executeCommand(Object(Predis\Command\StringGet))
#5 /app/index.php(32): Predis\Client-&gt;__call('get', Array)
#6 /app/index.php(32): Predis\Client-&gt;get('me in <b>/vendor/predis/predis/lib/Predis/Connection/AbstractConnection.php</b> on line <b>141</b><br />

@jdef
Copy link
Author

jdef commented Dec 3, 2014

from redis-cli within frontendController:

root@93a21dba-7a8b-11e4-9ddf-04012f416701:/# redis-cli -h 10.132.189.240 -p 10000                                                                                                                                                              
10.132.189.240:10000> dump messages                                                                                                                                                                                                            
Error: Server closed the connection

@jdef
Copy link
Author

jdef commented Dec 3, 2014

xref #93

@jdef
Copy link
Author

jdef commented Dec 3, 2014

Feeling pretty silly - the redis-master pod had not been started, but the redismaster had, which was the cause of the connection resets. The guestbook is now fully working on the host that has the docker build w/ hairpin support (moby/moby@9a917e7), the iptables changes, and the jdef/php-redis image.

It's not immediately clear to me why the iptables rule below is needed.

iptables -A INPUT -p tcp -m state --state NEW,ESTABLISHED -m tcp --dport 10000 -j ACCEPT

Perhaps the upstream rebase to 0.5x+ (see #88) will obviate the need for the docker hairpin networking?

@jdef
Copy link
Author

jdef commented Dec 3, 2014

Data point:

Dec  3 04:16:51 development-1823-93f kernel: [2211854.521025] IN=docker0 OUT= 
  PHYSIN=veth3f3a53b MAC=f6:a2:08:a9:26:ff:02:42:ac:11:00:03:08:00 SRC=172.17.0.3 
  DST=10.132.189.240 LEN=60 TOS=0x00 PREC=0x00 TTL=64 ID=27083 DF PROTO=TCP SPT=56873 
  DPT=10000 WINDOW=14600 RES=0x00 SYN URGP=0

with iptables rules:

root@development-1823-93f:~/docker# iptables-save|grep -e 10000
-A INPUT -p tcp -m state --state ESTABLISHED -m tcp --dport 10000 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 10000 -j LOG
-A INPUT -p tcp -m state --state NEW -m tcp --dport 10000 -j ACCEPT

@jdef
Copy link
Author

jdef commented Dec 3, 2014

The default rule for INPUT is currently DROP. We should probably allow all packets from the docker0 bridge to the host. Perhaps the default elastic mesosphere cluster configuration could take this into account.

Note: with these additional rules, the hacky docker hairpin networking is not required for the guestbook to work properly.

iptables -A INPUT -i docker0 -p tcp -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A INPUT -i docker0 -p udp -j ACCEPT

@jdef jdef added the priority label Dec 3, 2014
@jdef
Copy link
Author

jdef commented Dec 4, 2014

mesosphere has made changes to the default firewall rules in GCE, as per the prior comment: works like a champ! In order to access the frontend-service form the internet, two remaining steps are needed (reasonable):

  1. iptables of the slave to allow access to the service from the outside
  2. GCE network firewall rule to allow access to the service from the outside
$ iptables -A INPUT -i eth0 -p tcp -m state --state NEW,ESTABLISHED -m tcp --dport 9998 -j ACCEPT
$ iptables -A OUTPUT -p tcp -m tcp --sport 9998 -m state --state ESTABLISHED -j ACCEPT

GCE rule:

Source Ranges:
0.0.0.0/0
Allowed Protocols or Ports:
tcp:9998

@jdef jdef added this to the M2 milestone Dec 5, 2014
@jdef
Copy link
Author

jdef commented Dec 5, 2014

via michael jin (mesosphere): OK the IPTable changes have made their way to DO as well. Let us know if you run into anything else!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants