summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/sample/wg_tunnel/setup.sh
blob: 043a40be898fe56026e5354740e519d2eaabf16c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh

set -e

setup() {
	local mode=$1
	local dev=$2
	ip tuntap add $dev mode $mode
	ip l set up $dev
	ip a a 10.1.1.1/24 dev $dev
	ip r a 10.1.0.0/16 via 10.1.1.2 proto static
	ip a a 2001:470:de6f:5311::1/64 dev $dev
	ip r a 2001:470:de6f:5312::/64 via 2001:470:de6f:5311::2 proto static
	ip r a unreachable 2001:470:de6f:5310::/56 proto static || true
}

usage() {
	echo "Usage: $0 <mode> <dev>"
	exit 1
}

if [ $# -ne 2 ]; then
	usage
fi

setup $1 $2