# Docker network on 2 interfaces

**URL:** <https://forums.docker.com/t/docker-network-on-2-interfaces/142215>\
**Category:** General\
**Created:** [June 28, 2024, 6:56pm UTC](https://forums.docker.com/t/docker-network-on-2-interfaces/142215 "2024-06-28T18:56:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastien4444](https://avatars.discourse-cdn.com/v4/letter/s/f08c70/32.png) [@sebastien4444](https://forums.docker.com/u/sebastien4444)\
**Post date:** [June 28, 2024, 6:56pm UTC](https://forums.docker.com/t/docker-network-on-2-interfaces/142215/1 "2024-06-28T18:56:07Z")

</div>

Hi !

I currently have a custom NAS with OpenMediaVault that has 2 network interfaces (ep2s0 @IP 192.168.1.10 and ep3s0 @IP 192.168.1.11) and I am using Docker on it. Until now, I had only activated the ep2s0 interface on my NAS, and the Docker bridge network is using the IP 192.168.1.10.

Now, I would like to create a Docker (bridge) network that uses the ep3s0 interface (192.168.1.11), but I cannot find how to specify to Docker which interface to use when creating a network. The goal is to deploy an AdGuard container on this new ep3s0 interface, as it needs to open many ports that I am already using on my ep2s0 interface.

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [June 30, 2024, 11:19am UTC](https://forums.docker.com/t/docker-network-on-2-interfaces/142215/2 "2024-06-30T11:19:28Z")

</div>

When you search for this issue, you will find suggestions to add ip tables rules

1. [Bridged Network Source NAT — Kasm 1.15.0 documentation](https://kasmweb.com/docs/latest/how_to/bridged_network_source_nat.html)
2. [Unable to choose outbound (external) IP for containers · Issue #30053 · moby/moby · GitHub](https://github.com/moby/moby/issues/30053)

Interestingly I had to search for `--to-source` in the moby sourcecode to find the label which is actually mentioned on the second linked page.

> <https://github.com/moby/libnetwork/pull/2454>
>
> This commit allows a user to specify a Host IP via the
> com.docker.network.host\_…ipv4 label which is used as the
> Source IP during SNAT for bridge networks .
> 
> The use case is for hosts with multiple interfaces and
> this label can dictate which IP will be used as Source IP
> for North-South traffic
> 
> In the absence of this label, MASQUERADE is used which picks the Source IP
> based on Next Hop from the Route Table
> 
> Addresses: https://github.com/moby/moby/issues/30053
> 
> Signed-off-by: Arko Dasgupta \<arko.dasgupta@docker.com\>

So basically you can create a network like this:

```auto
docker network create net_4_192 \
  --opt com.docker.network.host_ipv4=192.168.4.192

```

or in compose

```auto
networks:
  default:
    driver_opts:
      com.docker.network.host_ipv4: 192.168.4.192

```

Note: When I used this label and chose a the IP address which was not in the same subnet as the destination IP (my local machine from a virtual machine created by multipass), the request was really slow. Hopefully it will not for you.
