Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save out0fmemory/1fcdc724ea2031cb95ae9c1966cdd52e to your computer and use it in GitHub Desktop.
Save out0fmemory/1fcdc724ea2031cb95ae9c1966cdd52e to your computer and use it in GitHub Desktop.

features

  • working macvlan with docker
  • systemd network devices
  • each container can reach the whole nework (full routing)
  • docker-compose.yml example with static ipv4 on macvlan
  • if no ip defined, container get a ip within 192.168.155.192/27

macvlan

docker network create \
                    -d macvlan \
                    -o parent=eth0 \
                    --subnet=192.168.155.0/24 \
                    --gateway=192.168.155.0 \
                    --ip-range 192.168.155.192/27 \
                    macvlan # the name
version: '3.5'
services:
whoami:
image: containous/whoami:latest
restart: unless-stopped
container_name: whoami
hostname: whoami
networks:
macvlan:
ipv4_address: 192.168.155.210
networks:
macvlan:
external: true
; /etc/systemd/network/eth0.network
[Match]
Name=eth0
[Network]
MACVLAN=vbridge
DHCP=yes
MulticastDNS=yes
; /etc/systemd/network/vbridge.netdev
[NetDev]
Name=vbridge
Kind=macvlan
[MACVLAN]
Mode=bridge
; /etc/systemd/network/vbridge.network
[Match]
Name=vbridge
[Network]
IPForward=yes
LinkLocalAddressing=no
Address=192.168.155.223/32
Gateway=192.168.155.1
DNS=192.168.155.1
[Route]
Destination=192.168.155.0/24
Gateway=192.168.155.1
Scope=global
GatewayOnlink=yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment