-
Notifications
You must be signed in to change notification settings - Fork 0
/
testbed.sh
executable file
·64 lines (48 loc) · 1.84 KB
/
testbed.sh
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# +------------------+ +------------------+
# | r0 | | r1 |
# | | | |
# | | | |
# | veth0 +------+ veth1 |
# | | | |
# | 10.0.0.1/24 10.0.0.2/24 |
# | | | |
# +------------------+ +------------------+
#
set -x
TMUX=sfw
IPP=ip
# Kill tmux previous session
tmux kill-session -t ${TMUX} 2>/dev/null
# Clean up previous network namespaces
$IPP -all netns delete
$IPP netns add r0
$IPP netns add r1
$IPP link add name veth0 netns r0 type veth peer name veth1 netns r1
###################
#### Node: r0 #####
###################
echo -e "\nNode: r0"
# not really required for this test
$IPP netns exec r0 sysctl -w net.ipv4.ip_forward=1
$IPP netns exec r0 sysctl -w net.ipv6.conf.all.forwarding=1
$IPP netns exec r0 $IPP link set dev lo up
$IPP netns exec r0 $IPP link set dev veth0 up
$IPP netns exec r0 $IPP addr add 10.0.0.1/24 dev veth0
###################
#### Node: r1 #####
###################
echo -e "\nNode: r1"
# not really required for this test
$IPP netns exec r1 sysctl -w net.ipv4.ip_forward=1
$IPP netns exec r1 sysctl -w net.ipv6.conf.all.forwarding=1
$IPP netns exec r1 $IPP link set dev lo up
$IPP netns exec r1 $IPP link set dev veth1 up
$IPP netns exec r1 $IPP addr add 10.0.0.2/24 dev veth1
sleep 2
## Create a new tmux session
tmux new-session -d -s $TMUX -n r0 $IPP netns exec r0 bash
tmux new-window -t $TMUX -n r1 $IPP netns exec r1 bash
tmux select-window -t :0
tmux set-option -g mouse on
tmux attach -t $TMUX