Skip to content

Instantly share code, notes, and snippets.

@nerdalert
Last active November 26, 2015 01:49
Show Gist options
  • Save nerdalert/6952e3c9756e2702178e to your computer and use it in GitHub Desktop.
Save nerdalert/6952e3c9756e2702178e to your computer and use it in GitHub Desktop.

MacVlan Example

Macvlan can be attractive because it is bridgeless.

add two namespaces

ip netns add ns1
ip netns add ns2

Attach the macvlan interface to the parent eth0 device

ip link add mv1 link eth0 type macvlan mode bridge
ip link add mv2 link eth0 type macvlan mode bridge
ip link set mv1 netns ns1
ip link set mv2 netns ns2
ip netns exec ns1 ip link set dev mv1 up
ip netns exec ns2 ip link set dev mv2 up

set ip addresses

ip netns exec ns1 ifconfig mv1 10.10.10.1/24 up
ip netns exec ns2 ifconfig mv2 10.10.10.2/24 up

Ping from namespaces ns1 to ns2 and verify reachbility

ip netns exec ns1 ping -c2 10.10.10.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment