Last active
November 24, 2023 21:59
-
-
Save casebeer/e670239898b926d05f47dbe510e7fd12 to your computer and use it in GitHub Desktop.
Macvlan bridge for host connectivity in Netplan and Networkd-dispatcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
network: | |
version: 2 | |
renderer: networkd | |
ethernets: | |
mvlan-bridge: | |
addresses: | |
- 192.168.0.10/32 | |
routes: | |
- to: 192.168.0.128/28 # docker macvlan address range | |
via: 192.168.0.10 | |
metric: 100 | |
## n.b. Netplan does not yet support macvlans, so have to configure | |
# the macvlan bridge in /etc/networkd-dispatcher/... scripts, | |
# then modify it as an 'ethernets' entry here for IP and routes | |
# https://bugs.launchpad.net/netplan/+bug/1664847/comments/19 | |
# | |
# Manual config steps: | |
# | |
# ip link add mvlan-bridge link eth0 type macvlan mode bridge | |
# ip addr add 192.168.0.10/32 dev mvlan-bridge | |
# ip link set mvlan-bridge up | |
# ip route add 192.168.0.128/28 dev mvlan-bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## TODO: Move this script to /etc/networkd-dispatcher/configured.d/ once we've upgraded to 22.04 Kinetic | |
ip link add mvlan-bridge link eth0 type macvlan mode bridge | |
# ip link add mvlan-bridge link eth0 type macvlan mode bridge | |
# ip addr add 192.168.0.10/32 dev mvlan-bridge | |
# ip link set mvlan-bridge up | |
# ip route add 192.168.0.128/28 dev mvlan-bridge | |
# Add to docker-compose macvlan network ipam.config: | |
# aux_addresses: | |
# mvlanbridge: 192.168.0.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
networks: | |
... | |
vlan-123: | |
driver: macvlan | |
driver_opts: | |
parent: eth0 | |
enable_ipv6: true | |
ipam: | |
config: | |
- subnet: 192.168.0.0/24 | |
gateway: 192.168.0.1 | |
ip_range: 192.168.0.128/28 # 14 usable addrs for macvlan containers, .129–.142 | |
aux_addresses: | |
mvlanbridge: 192.168.0.10 | |
- subnet: fe80:dead:beef::/80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment