IP Schema

Overview of the IP addressing scheme and network architecture used to isolate multiple development environments in a Vagrant-based Ansible setup with LXD containers and VirtualBox VMs.

The development environment uses a logical subnet layout to keep environments such as c2d and pxd separated while allowing internal communication. Each environment receives dedicated subnets for LXD containers and VirtualBox virtual machines.

Concept

  • Isolation per environment: Every environment (for example c2d or pxd) receives its own unique subnets. Traffic between the c2d and pxd environments remains completely separate.
  • Communication within an environment: Inside one environment the LXD containers and VirtualBox VMs can reach each other. Although they reside on different subnets, the host machine acts as a router and forwards traffic between the virtual network bridges via IP forwarding and NAT.

IP Schema Overview

The table below shows how a single /20 block provides the address space for multiple environments. The LXD bridge (lxdbr1) is configured once with this larger subnet. Environments are then logically separated by assigning them non-overlapping ranges inside that block. Only the ranges starting at 192.168.48.0 are shown.

EnvironmentLXD Network (containers)VirtualBox Network (VMs)
c2d192.168.48.0/24192.168.49.0/24
pxd192.168.50.0/24192.168.51.0/24
(reserved)192.168.52.0/24192.168.53.0/24
(reserved)192.168.54.0/24192.168.55.0/24

The block 192.168.48.0/20 covers addresses 192.168.48.0 through 192.168.63.255. The following command configures the LXD bridge inside this block:

lxc network set lxdbr1 ipv4.address=192.168.48.1/20

How Communication Works

Both LXD and VirtualBox create their own virtual network interfaces (bridges) on the host.

  • LXD typically provisions a bridge such as lxdbr1 with gateway 192.168.48.1.
  • VirtualBox creates a host-only adapter with gateway 192.168.49.1.

When an LXD container (for example 192.168.48.5) sends traffic to a VirtualBox VM (for example 192.168.49.10), the packets follow these steps:

  1. The container forwards the traffic to its default gateway (the host at 192.168.48.1).
  2. The Linux host receives the packets. Because IP forwarding is enabled, the host routes the traffic to the VirtualBox interface.
  3. The VirtualBox VM replies; the host routes the response back to the originating LXD container.

No additional tunneling or software is required; standard Linux networking, together with the Vagrant, LXD, and VirtualBox configurations, handles the forwarding transparently.

Benefits

  • Clear and predictable: It is immediately obvious which environment an IP address belongs to.
  • Secure isolation: A container in the pxd environment cannot reach resources in the c2d environment because the host does not share routes between them.
  • Scalable: A single /20 provides addresses for several environments.

Last modified July 10, 2026: dev setup ip schema C2-1540 (d639ac0)