Docker: Converting an existing legacy system to Dockerized form while maintaining original network scheme

Viewed 175

I'm in the midst of a project that made to convert an existing VOIP legacy system into a dockerized form. The existing system consists of 5 different Linux machines, each machine is having 2 different network interfaces - one exposed to the public WAN, and the other is a private Lan network. I plan on creating a docker compose file for setting up the orchestration.

The network roughly looks like this:

Server #1 Eth0: IP 192.168.0.200/24 Eth1: IP X.X.X.65/27

Server #2 Eth0: IP 192.168.0.201/24 Eth1: IP X.X.X.66/27

Server #3 Eth0: IP 192.168.0.202/24 Eth1: IP X.X.X.87/27

Server #4 Eth0: IP 192.168.0.203/24 Eth1: IP Y.Y.Y.240/27

Server #5 Eth0: IP 192.168.0.204/24 Eth1: IP Y.Y.Y.241/27

Servers 1-3 are part of the same subnet, so are servers 4-5.

I am trying to find the best way to convert this network setup into docker networks, I want every container to preserve his public IP (the one on Eth1, meaning that traffic generated from the container will keep the same public IP it had on the original server), but also to be able to communicate with every other docker container on the same private net, while also keeping it easily managable and having the least overhead possible.

Would it be possible to mix between a Bridge network and connect every docker container to it, while also having a Macvlan network for each docker container which will bind to a different network interface on host level?

Can I create only 2 network interfaces for the host machine, each for a different subnet, while maintaining the different IP addresses on them (one network interface will consist of 2 IPs, the other one of 3, and each interface will have a corresponding Macvlan docker network)?

Is there a better way to make this work?

EDIT

Using the nmtui command I've created an IPv4 interface with multiple IP addresses, I would like to connect 3 of my containers to this network interface, while providing each one of them with a different public IP. Based on the screenshot given below, would it be enough to create a single Macvlan network and assign each container with it's own IPv4 address? Reading about it online havn't provided me with a definite answer, but it seems likely that Docker engine will ignore this setting and use the defined primary IP instead for every container. Essentialy, I would like every container to receive traffic from it's own host IP, and delivere traffic from the same IP.

services:
  kamin:
    networks:
      kamin:
        priority: 1
        ipv4_address: "69.31.245.134"
networks:
  kamin:
    driver: macvlan
    driver_opts:
      parent: enp0s25
    ipam:
      config:
        - subnet: 69.30.245.130/29
          gateway: 69.31.245.129

enter image description here

1 Answers

I was able to make it work using 3 network interfaces on host level and 1 custom bridge and 2 ipvlan networks on docker level.

Related