#!/bin/bash -x
# sudo ifconfig vf0_0 down
# sudo ifconfig vf0_0 hw ether 00:11:11:11:11:11
# sudo ifconfig vf0_1 down
# sudo ifconfig vf0_1 hw ether 00:22:22:22:22:22
# sudo ifconfig vf0_2 down
# sudo ifconfig vf0_2 hw ether 00:33:33:33:33:33

sudo ifconfig vf0_0 192.168.200.10/24 up
sudo ifconfig vf0_1 192.168.210.10/24 up
# sudo ifconfig vf0_2 192.168.2.4/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.210.0/24 --aux-address="vf0_0=192.168.200.10" --aux-address="vf0_1=192.168.210.10"  --aux-address="vf0_2=192.168.200.11" -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.200.10/24
sudo ip netns exec ns_server ip link set dev vf0_0 up
sudo ip netns exec ns_server arp -s 192.168.210.10 00:15:4d:00:00:01 -i vf0_0

# sudo ip link set vf0_2 netns ns_server
# sudo ip netns exec ns_server ip addr add dev vf0_2 192.168.2.4/24
# sudo ip netns exec ns_server ip link set dev vf0_2 up
# sudo ip netns exec ns_server arp -s 192.168.2.3 00:22:22:22:22:22 -i vf0_2
# sudo ip netns exec ns_server arp -s 192.168.2.2 00:11:11:11:11:11 -i vf0_2

sudo arp -s 192.168.200.10 00:15:4d:00:00:00  -i vf0_1
# sudo arp -s 192.168.2.4 00:33:33:33:33:33 -i vf0_1
# sudo arp -s 192.168.210.41 04:3f:72:da:6b:9c -i vf0_1

sudo ip netns exec ns_server ethtool --offload  vf0_0  rx off  tx off
# sudo ethtool --offload  vf0_0  rx off  tx off
sudo ethtool --offload  vf0_1  rx off  tx off
# sudo ifconfig vf0_1 mtu 9000
# sudo ip netns exec ns_server ifconfig vf0_2 mtu 9000
# sudo ifconfig vf0_0 mtu 9000
# ip link add vethd1 type veth peer name br-vethd1
# ip link set vethd1 netns ns_server
# ip netns exec ns_server ip addr add 192.168.1.11/24 dev vethd1

# Create a bridge bridgek0
# sudo brctl addbr bridgek0
# sudo brctl addif bridgek0 br-vethd1
# sudo ip netns exec ns_server ip addr add 10.129.6.6/24 dev vethd1
# sudo ip netns exec ns_server ip link set vethd1 up
# sudo ip link set br-vethd1 up
# sudo ip addr add 10.129.6.5/24 dev bridgek0
# sudo ip link set bridgek0 up


# create veth cable for kafka
# sudo ip link add veth_nnic0 type veth peer name veth_nnic1
# sudo ip link set veth_nnic0 netns ns_server
# sudo ip netns exec ns_server ip addr add 10.128.2.201/24 dev veth_nnic0
# sudo ip netns exec ns_server ip link set dev veth_nnic0 up
# sudo ip addr add 10.128.2.200/24 dev veth_nnic1
# sudo ip link set dev veth_nnic1 up

