Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
IPVlan L3 Mode Two Host Example

Quick Paste Ipvlan L3 Instructions

  • Host #1
ip netns add ns1
ip link add link eth1 ipvl1 type ipvlan mode l3
ip link set dev ipvl1 netns ns1

ip netns exec ns1 bash
ip link set dev ipvl1 up
ip link set dev lo up
ip -4 addr add 127.0.0.1 dev lo

IPADDR_1=192.168.1.110
ip -4 addr add $IPADDR_1 dev ipvl1

NETWORK=192.168.1.0/24
ip route add $NETWORK dev ipvl1  proto kernel  scope link  src $IPADDR_1

ROUTER=192.168.1.1
ip -4 route add default via $ROUTER dev ipvl1
ip route add default via $ROUTER dev ipvl1  proto static  metric 1024
  • Host #2
ip netns add ns2
ip link add link eth1 ipvl2 type ipvlan mode l3
ip link set dev ipvl2 netns ns2

ip netns exec ns2 bash
ip link set dev ipvl2 up
ip link set dev lo up
ip -4 addr add 127.0.0.1 dev lo

IPADDR_2=192.168.1.120
ip -4 addr add $IPADDR_2 dev ipvl2

NETWORK=192.168.1.0/24
ip route add $NETWORK  dev ipvl2  proto kernel  scope link  src $IPADDR_2

ROUTER=192.168.1.1
ip route add default via $ROUTER dev ipvl2  proto static  metric 1024
ip -4 route add default via $ROUTER dev ipvl2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment