Skip to content

Instantly share code, notes, and snippets.

@karoltheguy
Last active June 5, 2022 20:13
Show Gist options
  • Select an option

  • Save karoltheguy/50b965d7765e4ad702ac6cd19189b625 to your computer and use it in GitHub Desktop.

Select an option

Save karoltheguy/50b965d7765e4ad702ac6cd19189b625 to your computer and use it in GitHub Desktop.
macvlan seen by host
#!/usr/bin/env bash
#Change these variables!
NIC_NAME="eth0"
DOCKER_ROUTING_INTERFACE_NAME="mymacvlan"
DOCKERNETWORK_IP_ADDRESS="192.168.0.249/32"
DOCKERNETWORK_IP_RANGE="192.168.0.64/26"
sleep 15 #Do not rush things if executing during boot. This line is not mandatory and can be removed.
ip link add ${DOCKER_ROUTING_INTERFACE_NAME} link ${NIC_NAME}type macvlan mode bridge ; ip addr add ${DOCKERNETWORK_IP_ADDRESS} dev ${DOCKER_ROUTING_INTERFACE_NAME} ; ip link set ${DOCKER_ROUTING_INTERFACE_NAME} up
ip route add ${DOCKERNETWORK_IP_RANGE} dev ${DOCKER_ROUTING_INTERFACE_NAME}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment