2021-03-01 17:15:15 +01:00
|
|
|
#!/bin/bash
|
2019-12-17 06:17:25 +01:00
|
|
|
|
|
|
|
set -e -x
|
|
|
|
|
2021-03-01 17:15:15 +01:00
|
|
|
set -o pipefail
|
2020-04-06 20:35:32 +02:00
|
|
|
|
2021-03-01 17:15:15 +01:00
|
|
|
mkdir -p logs
|
|
|
|
|
|
|
|
cleanup() {
|
|
|
|
set +e
|
|
|
|
if [ "$(jobs -r)" ]
|
|
|
|
then
|
|
|
|
sudo docker kill lighthouse1 host2 host3 host4
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
trap cleanup EXIT
|
|
|
|
|
|
|
|
sudo docker run --name lighthouse1 --rm nebula:smoke -config lighthouse1.yml -test
|
|
|
|
sudo docker run --name host2 --rm nebula:smoke -config host2.yml -test
|
|
|
|
sudo docker run --name host3 --rm nebula:smoke -config host3.yml -test
|
|
|
|
sudo docker run --name host4 --rm nebula:smoke -config host4.yml -test
|
|
|
|
|
|
|
|
sudo docker run --name lighthouse1 --device /dev/net/tun:/dev/net/tun --cap-add NET_ADMIN --rm nebula:smoke -config lighthouse1.yml 2>&1 | tee logs/lighthouse1 &
|
2019-12-17 06:17:25 +01:00
|
|
|
sleep 1
|
2021-03-01 17:15:15 +01:00
|
|
|
sudo docker run --name host2 --device /dev/net/tun:/dev/net/tun --cap-add NET_ADMIN --rm nebula:smoke -config host2.yml 2>&1 | tee logs/host2 &
|
2019-12-17 06:17:25 +01:00
|
|
|
sleep 1
|
2021-03-01 17:15:15 +01:00
|
|
|
sudo docker run --name host3 --device /dev/net/tun:/dev/net/tun --cap-add NET_ADMIN --rm nebula:smoke -config host3.yml 2>&1 | tee logs/host3 &
|
2019-12-17 06:17:25 +01:00
|
|
|
sleep 1
|
2021-03-01 17:15:15 +01:00
|
|
|
sudo docker run --name host4 --device /dev/net/tun:/dev/net/tun --cap-add NET_ADMIN --rm nebula:smoke -config host4.yml 2>&1 | tee logs/host4 &
|
2020-06-26 19:46:51 +02:00
|
|
|
sleep 1
|
2019-12-17 06:17:25 +01:00
|
|
|
|
|
|
|
set +x
|
|
|
|
echo
|
|
|
|
echo " *** Testing ping from lighthouse1"
|
|
|
|
echo
|
|
|
|
set -x
|
2021-03-01 17:15:15 +01:00
|
|
|
sudo docker exec lighthouse1 ping -c1 192.168.100.2
|
|
|
|
sudo docker exec lighthouse1 ping -c1 192.168.100.3
|
2019-12-17 06:17:25 +01:00
|
|
|
|
|
|
|
set +x
|
|
|
|
echo
|
|
|
|
echo " *** Testing ping from host2"
|
|
|
|
echo
|
|
|
|
set -x
|
2021-03-01 17:15:15 +01:00
|
|
|
sudo docker exec host2 ping -c1 192.168.100.1
|
2020-06-26 19:46:51 +02:00
|
|
|
# Should fail because not allowed by host3 inbound firewall
|
2021-03-01 17:15:15 +01:00
|
|
|
! sudo docker exec host2 ping -c1 192.168.100.3 -w5 || exit 1
|
2019-12-17 06:17:25 +01:00
|
|
|
|
|
|
|
set +x
|
|
|
|
echo
|
|
|
|
echo " *** Testing ping from host3"
|
|
|
|
echo
|
|
|
|
set -x
|
2021-03-01 17:15:15 +01:00
|
|
|
sudo docker exec host3 ping -c1 192.168.100.1
|
|
|
|
sudo docker exec host3 ping -c1 192.168.100.2
|
2020-06-26 19:46:51 +02:00
|
|
|
|
|
|
|
set +x
|
|
|
|
echo
|
|
|
|
echo " *** Testing ping from host4"
|
|
|
|
echo
|
|
|
|
set -x
|
2021-03-01 17:15:15 +01:00
|
|
|
sudo docker exec host4 ping -c1 192.168.100.1
|
2020-06-26 19:46:51 +02:00
|
|
|
# Should fail because not allowed by host4 outbound firewall
|
2021-03-01 17:15:15 +01:00
|
|
|
! sudo docker exec host4 ping -c1 192.168.100.2 -w5 || exit 1
|
|
|
|
! sudo docker exec host4 ping -c1 192.168.100.3 -w5 || exit 1
|
2020-06-26 19:46:51 +02:00
|
|
|
|
|
|
|
set +x
|
|
|
|
echo
|
|
|
|
echo " *** Testing conntrack"
|
|
|
|
echo
|
|
|
|
set -x
|
|
|
|
# host2 can ping host3 now that host3 pinged it first
|
2021-03-01 17:15:15 +01:00
|
|
|
sudo docker exec host2 ping -c1 192.168.100.3
|
2020-06-26 19:46:51 +02:00
|
|
|
# host4 can ping host2 once conntrack established
|
2021-03-01 17:15:15 +01:00
|
|
|
sudo docker exec host2 ping -c1 192.168.100.4
|
|
|
|
sudo docker exec host4 ping -c1 192.168.100.2
|
|
|
|
|
|
|
|
sudo docker exec host4 sh -c 'kill 1'
|
|
|
|
sudo docker exec host3 sh -c 'kill 1'
|
|
|
|
sudo docker exec host2 sh -c 'kill 1'
|
|
|
|
sudo docker exec lighthouse1 sh -c 'kill 1'
|
|
|
|
sleep 1
|