jpetazzo / pipework

Software-Defined Networking tools for LXC (LinuX Containers)
Apache License 2.0
4.22k stars 727 forks source link

No work here. Ubuntu 13.10 on VM #22

Closed bySabi closed 10 years ago

bySabi commented 10 years ago

1- First I start container#1

  $ docker run -i -t test /bin/bash

2- then container#2

$ docker run -i -t test /bin/bash

**\ Containers based on image: stackbrew/ubuntu:13.10

3- On host terminal run:

  $ pipework br1 7187a6f56000 192.168.1.1/24
  $ pipework br1 62bb18c85858 192.168.1.2/24

4- Interfaces & route setting inside containers:

container#1

root@62bb18c85858:/# ifconfig 
eth0      Link encap:Ethernet  HWaddr 86:46:72:d0:9f:38  
          inet addr:172.17.0.4  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::8446:72ff:fed0:9f38/64 Scope:Link
          UP BROADCAST RUNNING  MTU:1500  Metric:1
          RX packets:16 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1296 (1.2 KB)  TX bytes:648 (648.0 B)

eth1      Link encap:Ethernet  HWaddr a2:2d:fa:5d:61:d0  
          inet addr:192.168.1.2  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fe80::a02d:faff:fe5d:61d0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:648 (648.0 B)  TX bytes:648 (648.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

root@62bb18c85858:/# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         172.17.42.1     0.0.0.0         UG    0      0        0 eth0
172.17.0.0      *               255.255.0.0     U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 eth1

container#2

root@7187a6f56000:/# ifconfig 
eth0      Link encap:Ethernet  HWaddr 42:a0:0c:94:ec:35  
          inet addr:172.17.0.5  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::40a0:cff:fe94:ec35/64 Scope:Link
          UP BROADCAST RUNNING  MTU:1500  Metric:1
          RX packets:9 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:690 (690.0 B)  TX bytes:648 (648.0 B)

eth1      Link encap:Ethernet  HWaddr e2:f9:e0:60:82:77  
          inet addr:192.168.1.1  Bcast:0.0.0.0  Mask:255.255.255.0
          inet6 addr: fe80::e0f9:e0ff:fe60:8277/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:648 (648.0 B)  TX bytes:648 (648.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

root@7187a6f56000:/# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         172.17.42.1     0.0.0.0         UG    0      0        0 eth0
172.17.0.0      *               255.255.0.0     U     0      0        0 eth0
192.168.1.0     *               255.255.255.0   U     0      0        0 eth1

host interfaces

root@UbuntuServer:~# ifconfig 
br1       Link encap:Ethernet  HWaddr ca:0c:bc:d3:91:9e  
          inet6 addr: fe80::4ce3:c9ff:fe70:6e47/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:536 (536.0 B)  TX bytes:648 (648.0 B)

docker0   Link encap:Ethernet  HWaddr fe:8b:22:36:61:39  
          inet addr:172.17.42.1  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::a8a1:bff:feb5:56e1/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:41 errors:0 dropped:0 overruns:0 frame:0
          TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:2522 (2.5 KB)  TX bytes:1152 (1.1 KB)

eth0      Link encap:Ethernet  HWaddr 00:0c:29:8c:fb:58  
          inet addr:192.168.0.32  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe8c:fb58/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1539 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1366 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:171156 (171.1 KB)  TX bytes:210873 (210.8 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:76 errors:0 dropped:0 overruns:0 frame:0
          TX packets:76 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:5868 (5.8 KB)  TX bytes:5868 (5.8 KB)

lxcbr0    Link encap:Ethernet  HWaddr c2:83:ee:7f:5e:51  
          inet addr:10.0.3.1  Bcast:10.0.3.255  Mask:255.255.255.0
          inet6 addr: fe80::c083:eeff:fe7f:5e51/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:648 (648.0 B)

veth623UAK Link encap:Ethernet  HWaddr fe:8b:22:36:61:39  
          inet6 addr: fe80::fc8b:22ff:fe36:6139/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:11 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:816 (816.0 B)  TX bytes:858 (858.0 B)

vethUR1YOL Link encap:Ethernet  HWaddr fe:e2:51:5d:37:28  
          inet6 addr: fe80::fce2:51ff:fe5d:3728/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:11 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:816 (816.0 B)  TX bytes:1506 (1.5 KB)

vethl2088 Link encap:Ethernet  HWaddr ca:0c:bc:d3:91:9e  
          inet6 addr: fe80::c80c:bcff:fed3:919e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:648 (648.0 B)  TX bytes:648 (648.0 B)

vethl2260 Link encap:Ethernet  HWaddr 72:a3:56:80:76:71  
          inet6 addr: fe80::70a3:56ff:fe80:7671/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:648 (648.0 B)  TX bytes:648 (648.0 B)

Then:

I can ping each containers on subnet: 172.17.0.0

$  ping 172.17.0.4 
   PING 172.17.0.4 (172.17.0.4) 56(84) bytes of data.
   64 bytes from 172.17.0.4: icmp_seq=1 ttl=64 time=0.258 ms
.
.

I can´t not ping containers on subnet: 192.168.1.0

$ ping 192.168.1.2
   PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
   From 192.168.1.1 icmp_seq=1 Destination Host Unreachable
.
.
bySabi commented 10 years ago

Ok is seen that I have to add br0 bridge first to /etc/network/interfaces

Old set´s:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
  address 192.168.0.32
  netmask 255.255.255.0
  network 192.168.0.0
  broadcast 192.168.0.255
  gateway 192.168.0.254
  dns-nameservers 192.168.0.254

new set´s

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet manual

# bridge
auto br0
iface br0 inet static
  address 192.168.0.32
  netmask 255.255.255.0
  network 192.168.0.0
  broadcast 192.168.0.255
  gateway 192.168.0.254
  dns-nameservers 192.168.0.254
  bridge_ports eth0
  bridge_stp off
  bridge_fd 0
  bridge_maxwait 0

is working with, little obvious :) ...

  $ pipework br0 7187a6f56000 192.168.1.1/24
  $ pipework br0 62bb18c85858 192.168.1.2/24

it´s expect behaviour, add br0 manually?

jpetazzo commented 10 years ago

Yes, that's expected. By default, the network will be purely private between the containers. If you want to be able to ping the containers from the Docker host, you have to give the Docker host an IP address on that network, as explained here: https://github.com/jpetazzo/pipework#peeking-inside-the-private-network

Let me know if the explanation needs to be improved!