moby / moby/libnetwork

same network multiple host interfaces: "failed to allocate gateway (192.168.34.1): Address already in use"

Open
#2,250 1 comment 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
2.2k
Forks
875
PR merge metrics
No merged PRs in 30d

Description

Having two network interfaces connected to the same network:

First network:

$ docker network create -d macvlan \
--subnet 192.168.34.0/24 \
--gateway 192.168.34.1 \
-o parent=eth0 \
--ip-range 192.168.34.2/32 \
eth0-test
2248a7b940e2755a72320b8a58e24a950aa1883b00538930e239b89940cb90c6

Second network:

$ docker network create -d macvlan \
--subnet 192.168.34.0/24 \
--gateway 192.168.34.1 \
-o parent=eth1 \
--ip-range 192.168.34.3/32 \
eth1-test
Error response from daemon: failed to allocate gateway (192.168.34.1): Address already in use

There are related issues:
https://github.com/moby/moby/issues/35834
https://github.com/mesg-foundation/core/issues/268

Probably it the cause, in the way that, gateway address is treated as unique, which is not a case. Related issues above, have problem with cleanup for network re-creation. In my case, I need same default gateway for multiple networks explicitly.

When configuration is used for swarm, network create --config-only works for two networks:

Host1:

$ docker network create --config-only \
--subnet 192.168.34.0/24 \
--gateway 192.168.34.1 \
-o parent=eth0 \
--ip-range 192.168.34.2/32 \
eth0-net
378ecbdfc42723cc10205f4d8a1f9dda6d9508066c11005b36c64fccfcccd5dc
$ docker network create --config-only \
--subnet 192.168.34.0/24 \
--gateway 192.168.34.1 \
-o parent=eth1 \
--ip-range 192.168.34.3/32 \
eth1-net
f52e8d6f3a61af51712655ed99b14867a30ae243f49bd6affd7e7839f720b39e

Host2:

$ docker network create --config-only \
--subnet 192.168.34.0/24 \
--gateway 192.168.34.1 \
-o parent=eth0 \
--ip-range 192.168.34.4/32 \
eth0-net
1b34ff55781dee04e14b6907150ffd3d054130cd93d62964ed21d400f3c00358
$ docker network create --config-only \
--subnet 192.168.34.0/24 \
--gateway 192.168.34.1 \
-o parent=eth1 \
--ip-range 192.168.34.5/32 \
eth1-net
91bc6fb5320bbb4546e51b5b46e268779fa4afa471b5191ef81c3e6a4a5f4f29

Host3: omitted

Host-any:

$ docker network create -d macvlan --scope swarm \
--config-from eth0-net eth0-swarm-net
sfulig6iml4t4vhfk1eqzlvnb
$ docker network create -d macvlan --scope swarm \
--config-from eth1-net eth1-swarm-net
79zpw60z6bd3c9giblfv4x1ev

Service fails:

$ docker service create --mode global --name test-service1 \
--network eth0-swarm-net \
--network eth1-swarm-net \
donch/net-tool
judv0bhx3oy2ze3gj89yfwqf2
overall progress: 0 out of 3 tasks 
overall progress: 0 out of 3 tasks 
overall progress: 0 out of 3 tasks 
overall progress: 0 out of 3 tasks 
overall progress: 0 out of 3 tasks 
furfq6c7v38a: failed to allocate gateway (192.168.34.1): Address already in use 
uxsil16voy3o: failed to allocate gateway (192.168.34.1): Address already in use 
to2akg3m2sdw: failed to allocate gateway (192.168.34.1): Address already in use 
^COperation continuing in background.
Use `docker service ps judv0bhx3oy2ze3gj89yfwqf2` to check progress.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the two macvlan network creation commands and the Swarm service setup shown in the issue. Trace the gateway allocation path in libnetwork, using the reported "Address already in use" failure as the starting symptom. Done means networks on eth0 and eth1 can share 192.168.34.1 without the service tasks failing.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, go
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.