master-thesis/p4app/static-mapping.sh

39 lines
934 B
Bash

#!/bin/sh
set -x
# cleanup
for i in 1 2 3 4; do
mx h$i "ip addr flush dev $dev"
done
# host 1/2+42 need NDP for reaching themselves
for i in 1 2; do
dev="h$i-eth0"
# add and enable ipv6
mx h$i "sysctl net.ipv6.conf.{lo,h$i-eth0}.disable_ipv6=0"
mx h$i "ip addr add 2001:db8:6::$i/64 dev $dev"
mx h$i "ip -6 route add default via 2001:db8:6::42"
# add neighbors
for j in 1 2 42; do
mx h$i "ip -6 neigh add 2001:db8:61::${j} dev $dev lladdr 00:00:0a:00:00:0${j}"
mx h$i "ip -6 neigh add 2001:db8:62::${j} dev $dev lladdr 00:00:0a:00:00:0${j}"
done
done
# host 3/4 need ARP, also need access to .42 (virtual IP)
for i in 3 4; do
dev="h$i-eth0"
mx h$i "ip addr add 10.0.0.$i/24 dev $dev"
# add arp
for j in 1 2 42; do
mx h$i "ip neigh add 10.0.0.${j} dev $dev lladdr 00:00:0a:00:00:${j}"
done
done
for i in 1 2 3 4; do
mx h$i "ip neigh show"
done