#!/bin/bash -x

sudo ifconfig vf0_0 192.168.2.2/24 up
sudo ifconfig vf0_1 192.168.2.3/24 up

# create a MAC VLAN for docker attached to vf0_1
echo "y" | docker system prune
docker network create -d macvlan --subnet=192.168.2.0/24 --aux-address="vf0_0=192.168.2.2" --aux-address="vf0_1=192.168.2.3" -o parent=vf0_1 pub_net

# move vf0_0 into its own namespace
# sudo ip netns exec ns_server ip link set vf0_0 netns 1
# sudo ip netns delete ns_server
# sudo ip netns add ns_server

# sudo ip link set vf0_0 netns ns_server
# sudo ip netns exec ns_server ip addr add dev vf0_0 192.168.2.2/24
# sudo ip netns exec ns_server ip link set dev vf0_0 up

# sudo ip netns exec ns_server arp -s 192.168.2.3 00:22:22:22:22:22 -i vf0_0
# sudo ip netns exec ns_server arp -s 192.168.2.4 00:33:33:33:33:33 -i vf0_0

# sudo arp -s 192.168.2.2 00:11:11:11:11:11 -i vf0_1
# sudo arp -s 192.168.2.4 00:33:33:33:33:33 -i vf0_1