docker-net-dhcp
docker-net-dhcp copied to clipboard
Help wanted!
Hi @devplayer0 !
How is going with the golang version? Is the golang branch ready to run?
I am currently doing an experiment on my wireless bandwidth allocation system, and want to use docker containers to simulate the users. The problem I am facing is how to allocate IP address using the DHCP service on my router. So, the router can see the IP address of containers and control the bandwidth of them accordingly.
After days of searching and testing, I found you repo, which should perfectly solve my problem. But following your configuration guide, I got stuck on the last step like #2.
Set up commands:
root@aaron-ubuntu:/home/aaron/Downloads/docker# ip link add my-bridge type bridge
root@aaron-ubuntu:/home/aaron/Downloads/docker# ip link set my-bridge up
root@aaron-ubuntu:/home/aaron/Downloads/docker# ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:fe:25:45:2c txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s25: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.72 netmask 255.255.255.0 broadcast 192.168.1.255
ether 28:xxxxxxxxxxx:3f txqueuelen 1000 (Ethernet)
RX packets 89696 bytes 128312381 (128.3 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12962 bytes 1441554 (1.4 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 20 memory 0xf1500000-f1520000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 170 bytes 13353 (13.3 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 170 bytes 13353 (13.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
my-bridge: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 169.254.143.243 netmask 255.255.0.0 broadcast 169.254.255.255
ether be:d9:5a:25:a5:c7 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 38 bytes 6374 (6.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp3s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether f4:b7:e2:c8:11:09 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
root@aaron-ubuntu:/home/aaron/Downloads/docker# ip link set enp0s25 up
root@aaron-ubuntu:/home/aaron/Downloads/docker# ip link set enp0s25 master my-bridge
root@aaron-ubuntu:/home/aaron/Downloads/docker# dhcpcd my-bridge
sending commands to master dhcpcd process
root@aaron-ubuntu:/home/aaron/Downloads/docker# ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:fe:25:45:2c txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s25: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.72 netmask 255.255.255.0 broadcast 192.168.1.255
ether 28:xxxxxxxxxxx:3f txqueuelen 1000 (Ethernet)
RX packets 89696 bytes 128312381 (128.3 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 12962 bytes 1441554 (1.4 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 20 memory 0xf1500000-f1520000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 170 bytes 13353 (13.3 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 170 bytes 13353 (13.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
my-bridge: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 169.254.143.243 netmask 255.255.0.0 broadcast 169.254.255.255
ether 28:xxxxxxxxxxx:3f txqueuelen 1000 (Ethernet)
RX packets 17 bytes 1022 (1.0 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 45 bytes 7814 (7.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
root@aaron-ubuntu:/home/aaron/Downloads/docker# docker network create -d devplayer0/net-dhcp:latest --ipam-driver null -o bridge=my-bridge my-dhcp-net
3c107622e099b754586c483073b1cb517d14ec8541d4fec047fd18aa2bd0240f
root@aaron-ubuntu:/home/aaron/Downloads/docker# ./docker run --rm -ti --network my-dhcp-net alpine
./docker: Error response from daemon: failed to create endpoint charming_roentgen on network my-dhcp-net: NetworkDriver.CreateEndpoint: Timed out waiting for lease from udhcpc.
Below is the log:
root@aaron-ubuntu:/home/aaron/Downloads/docker# ./dockerd
INFO[2020-08-06T17:20:08.192055121+07:00] Starting up
INFO[2020-08-06T17:20:08.193839368+07:00] parsed scheme: "unix" module=grpc
INFO[2020-08-06T17:20:08.193880534+07:00] scheme "unix" not registered, fallback to default scheme module=grpc
INFO[2020-08-06T17:20:08.193990954+07:00] ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0 <nil>}] } module=grpc
INFO[2020-08-06T17:20:08.194008171+07:00] ClientConn switching balancer to "pick_first" module=grpc
INFO[2020-08-06T17:20:08.194096651+07:00] pickfirstBalancer: HandleSubConnStateChange: 0xc0008cc770, CONNECTING module=grpc
INFO[2020-08-06T17:20:08.194113055+07:00] blockingPicker: the picked transport is not ready, loop back to repick module=grpc
INFO[2020-08-06T17:20:08.194609079+07:00] pickfirstBalancer: HandleSubConnStateChange: 0xc0008cc770, READY module=grpc
INFO[2020-08-06T17:20:08.195795715+07:00] parsed scheme: "unix" module=grpc
INFO[2020-08-06T17:20:08.195880981+07:00] scheme "unix" not registered, fallback to default scheme module=grpc
INFO[2020-08-06T17:20:08.195950908+07:00] ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/containerd.sock 0 <nil>}] } module=grpc
INFO[2020-08-06T17:20:08.196014803+07:00] ClientConn switching balancer to "pick_first" module=grpc
INFO[2020-08-06T17:20:08.196270999+07:00] pickfirstBalancer: HandleSubConnStateChange: 0xc000622590, CONNECTING module=grpc
INFO[2020-08-06T17:20:08.196324870+07:00] blockingPicker: the picked transport is not ready, loop back to repick module=grpc
INFO[2020-08-06T17:20:08.197008530+07:00] pickfirstBalancer: HandleSubConnStateChange: 0xc000622590, READY module=grpc
ERRO[0000] * Running on unix:///run/docker/plugins/net-dhcp.sock (Press CTRL+C to quit) plugin=03e99022fe5f1af88120c3e1044dadc75700a4c7c1ea39255ff1f00a9759a9a4
INFO[2020-08-06T17:20:11.844785741+07:00] [graphdriver] using prior storage driver: overlay2
WARN[2020-08-06T17:20:11.861201865+07:00] Your kernel does not support swap memory limit
WARN[2020-08-06T17:20:11.861260750+07:00] Your kernel does not support cgroup rt period
WARN[2020-08-06T17:20:11.861289163+07:00] Your kernel does not support cgroup rt runtime
WARN[2020-08-06T17:20:11.861309454+07:00] Your kernel does not support cgroup blkio weight
WARN[2020-08-06T17:20:11.861327408+07:00] Your kernel does not support cgroup blkio weight_device
INFO[2020-08-06T17:20:11.861687592+07:00] Loading containers: start.
ERRO[0003] <local> - - [06/Aug/2020 10:20:11] "POST /NetworkDriver.GetCapabilities HTTP/1.1" 200 - plugin=03e99022fe5f1af88120c3e1044dadc75700a4c7c1ea39255ff1f00a9759a9a4
INFO[2020-08-06T17:20:12.004358538+07:00] Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. Daemon option --bip can be used to set a preferred IP address
INFO[2020-08-06T17:20:12.054813245+07:00] Loading containers: done.
INFO[2020-08-06T17:20:12.104819838+07:00] Docker daemon commit=aeac9490dc graphdriver(s)=overlay2 version=19.03.0
INFO[2020-08-06T17:20:12.104910408+07:00] Daemon has completed initialization
INFO[2020-08-06T17:20:12.172001924+07:00] API listen on /var/run/docker.sock
ERRO[0272] <local> - - [06/Aug/2020 10:24:40] "POST /NetworkDriver.CreateNetwork HTTP/1.1" 200 - plugin=03e99022fe5f1af88120c3e1044dadc75700a4c7c1ea39255ff1f00a9759a9a4
ERRO[0317] <local> - - [06/Aug/2020 10:25:26] "POST /NetworkDriver.CreateEndpoint HTTP/1.1" 500 - plugin=03e99022fe5f1af88120c3e1044dadc75700a4c7c1ea39255ff1f00a9759a9a4
WARN[2020-08-06T17:25:26.126010029+07:00] 638a28b2d97b0408df2c8f05c498e5ee6881b385f872ffd37d5ba1108475349b cleanup: failed to unmount IPC: umount /var/lib/docker/containers/638a28b2d97b0408df2c8f05c498e5ee6881b385f872ffd37d5ba1108475349b/mounts/shm, flags: 0x2: no such file or directory
ERRO[2020-08-06T17:25:26.135476524+07:00] 638a28b2d97b0408df2c8f05c498e5ee6881b385f872ffd37d5ba1108475349b cleanup: failed to delete container from containerd: no such container
ERRO[2020-08-06T17:25:26.140326173+07:00] Handler for POST /v1.40/containers/638a28b2d97b0408df2c8f05c498e5ee6881b385f872ffd37d5ba1108475349b/start returned error: failed to create endpoint charming_roentgen on network my-dhcp-net: NetworkDriver.CreateEndpoint: Timed out waiting for lease from udhcpc
Could you help to localize the error I might have? I got no internet connection after command ip link set enp0s25 master my-bridge
Could you release a golang (stable) version or give some instructions on how to compile the golang branch locally?
Looking forward to your reply and I appreciate your help very much!
Hi there! Unfortunately I've been quite busy so the Go rewrite is still in the early stages :(
It makes sense to lose connection after attaching the wired interface to the bridge. I don't think it matters too much, but you should delete the IP address on your wired interface (i.e. sudo ip addr del 192.168.1.72/24 dev enp0s25). Also, try running your DHCP client in the foreground on the bridge and see what it outputs, as it seems an IP address isn't being acquired (only an autoconfigured one). For dhcpcd do sudo dhcpcd -B my-bridge.
My guess is there is some issue with your DHCP setup, as the plugin is also failing to get a lease. Maybe run Wireshark on enp0s25 and see if the DHCP packets are going while dhcpcd is running?
Hope this helps, let me know how it goes.
Hi devplayer0!
Thanks for your help!
Following your instructions, I firstly test dhcpcd with dhcpcd -N enp0s25 to renew the lease of enp0s25. As shown in the screenshot, it works fine. And this time, my-bridge successfully got the IP address 192.168.1.135 by dhcpcd -B my-bridge. Also, after sudo ip add del 192.168.1.131/24 dev enp0s25, I got the internet connection again.
But, the timeout error still occurred:
docker: Error response from daemon: failed to create endpoint infallible_bohr on network my-dhcp-net: NetworkDriver.CreateEndpoint: Timed out waiting for lease from udhcpc.
From the Wireshark log, it seems that the DHCP client run by the plugin keeps sending the DHCP Discover but the DHCP server did not send back the DHCP offer so that the DHCP process ended in the first step.
Can you see what's the problem so far? Do I need to provide more information?
Again, thanks a lot for your help!
Wireshark sreenshot:

Command history:
root@aaron-ubuntu:/home/aaron# ip link add my-bridge type bridge
root@aaron-ubuntu:/home/aaron# ip link set my-bridge up
root@aaron-ubuntu:/home/aaron# dhcpcd -B my-bridge
sending commands to master dhcpcd process
root@aaron-ubuntu:/home/aaron# dhcpcd -N enp0s25
sending commands to master dhcpcd process
root@aaron-ubuntu:/home/aaron# ip link set enp0s25 up
root@aaron-ubuntu:/home/aaron# dhcpcd -N enp0s25
sending commands to master dhcpcd process
root@aaron-ubuntu:/home/aaron# ip link set enp0s25 master my-bridge
root@aaron-ubuntu:/home/aaron# ifconfig
enp0s25: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.131 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::65c5:4d45:e034:cb4 prefixlen 64 scopeid 0x20<link>
inet6 fe80::1b2e:f498:f36e:da79 prefixlen 64 scopeid 0x20<link>
ether 28:d2:44:09:7b:3f txqueuelen 1000 (Ethernet)
RX packets 1097 bytes 735998 (735.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1039 bytes 158739 (158.7 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 20 memory 0xf1500000-f1520000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 175 bytes 12449 (12.4 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 175 bytes 12449 (12.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
my-bridge: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 169.254.41.168 netmask 255.255.0.0 broadcast 169.254.255.255
inet6 fe80::ae38:da4c:9885:8550 prefixlen 64 scopeid 0x20<link>
ether 28:d2:44:09:7b:3f txqueuelen 1000 (Ethernet)
RX packets 37 bytes 3998 (3.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 46 bytes 7064 (7.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp3s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether f4:b7:e2:c8:11:09 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
root@aaron-ubuntu:/home/aaron# dhcpcd -B my-bridge
sending commands to master dhcpcd process
root@aaron-ubuntu:/home/aaron# ifconfig
enp0s25: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.131 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::65c5:4d45:e034:cb4 prefixlen 64 scopeid 0x20<link>
inet6 fe80::1b2e:f498:f36e:da79 prefixlen 64 scopeid 0x20<link>
ether 28:d2:44:09:7b:3f txqueuelen 1000 (Ethernet)
RX packets 1165 bytes 742995 (742.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1140 bytes 168403 (168.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 20 memory 0xf1500000-f1520000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 175 bytes 12449 (12.4 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 175 bytes 12449 (12.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
my-bridge: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.135 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::ae38:da4c:9885:8550 prefixlen 64 scopeid 0x20<link>
ether 28:d2:44:09:7b:3f txqueuelen 1000 (Ethernet)
RX packets 105 bytes 9771 (9.7 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 67 bytes 9208 (9.2 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp3s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether f4:b7:e2:c8:11:09 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
root@aaron-ubuntu:/home/aaron# ip addr del 192.168.1.131/24 dev enp0s25
root@aaron-ubuntu:/home/aaron# ifconfig
enp0s25: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet6 fe80::65c5:4d45:e034:cb4 prefixlen 64 scopeid 0x20<link>
inet6 fe80::1b2e:f498:f36e:da79 prefixlen 64 scopeid 0x20<link>
ether 28:d2:44:09:7b:3f txqueuelen 1000 (Ethernet)
RX packets 1284 bytes 772995 (772.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1343 bytes 189160 (189.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 20 memory 0xf1500000-f1520000
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 192 bytes 14179 (14.1 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 192 bytes 14179 (14.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
my-bridge: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.135 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::ae38:da4c:9885:8550 prefixlen 64 scopeid 0x20<link>
ether 28:d2:44:09:7b:3f txqueuelen 1000 (Ethernet)
RX packets 223 bytes 37577 (37.5 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 133 bytes 16857 (16.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp3s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether f4:b7:e2:c8:11:09 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
root@aaron-ubuntu:/home/aaron# docker network create -d devplayer0/net-dhcp:latest --ipam-driver null -o bridge=my-bridge my-dhcp-net
8679ea85842bc962bd6e2a233a86d88e256a2287b192b1180fe543afc2c6d9eb
root@aaron-ubuntu:/home/aaron# docker run --rm -ti --network my-dhcp-net alpine
docker: Error response from daemon: failed to create endpoint infallible_bohr on network my-dhcp-net: NetworkDriver.CreateEndpoint: Timed out waiting for lease from udhcpc.
Hi @devplayer0 ! How are you doing these days? I have found another alternative to do my experiment, but your plugin is still the most suitable one. Looking forward to your reply when you're free.
Hey, sorry for not getting back to you. Thanks for sending on the screenshot.
Good you got DHCP going on your bridge, strange it's not working for the plugin. Any chance you could run Wireshark on the Ethernet interface only and send me a .pcap so I can take a look at the requests being sent out?
I experience the same Issue and recorded the dhcp reqest beeing send:
TIME: 2020-12-28 16:34:46.401
IP: 0.0.0.0 (e2:b9:3c:6b:28:94) > 255.255.255.255 (ff:ff:ff:ff:ff:ff)
OP: 1 (BOOTPREQUEST)
HTYPE: 1 (Ethernet)
HLEN: 6
HOPS: 0
XID: 727d4a71
SECS: 10
FLAGS: 0
CIADDR: 0.0.0.0
YIADDR: 0.0.0.0
SIADDR: 0.0.0.0
GIADDR: 0.0.0.0
CHADDR: e2:b9:3c:6b:28:94:00:00:00:00:00:00:00:00:00:00
SNAME: .
FNAME: .
OPTION: 53 ( 1) DHCP message type 1 (DHCPDISCOVER)
OPTION: 61 ( 7) Client-identifier 01:e2:b9:3c:6b:28:94
OPTION: 57 ( 2) Maximum DHCP message size 576
OPTION: 55 ( 7) Parameter Request List 1 (Subnet mask)
3 (Routers)
6 (DNS server)
12 (Host name)
15 (Domainname)
28 (Broadcast address)
42 (NTP servers)
OPTION: 60 ( 6) Vendor class identifier docker
I've come back to work on the rewrite at last! If you're still interested, see https://github.com/devplayer0/docker-net-dhcp/issues/12#issuecomment-856267625 for a brief explanation on my progress.
I've released the Go rewrite, feel free to try it out and let me know if this is still an issue.