forked from vincentbernat/network-lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup
executable file
·53 lines (44 loc) · 1.23 KB
/
setup
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
#!/bin/sh
cd "$(dirname "$(readlink -f "$0")")"
. ../common/lab-setup
spawn vm C1 network 1 # Clients
spawn vm LB network 1,2 # LB
# Backends
NB=3
for i in $(seq 1 $NB); do
spawn vm S$i network 2
done
run
case $uts in
C1)
ip addr add 203.0.113.10/24 dev eth0
# Additional IP to be used as source
for i in $(seq 100 200); do
ip addr add 203.0.113.$i/32 dev lo
done
;;
LB)
ip addr add 203.0.113.15/24 dev eth0
ip addr add 10.234.79.1/24 dev eth1
ip route add default via 203.0.113.10
sysctl -qw net/ipv4/ip_forward=1
# Setup IPVS
modprobe ip_vs
[ ! -f ip_vs_mh.ko ] || insmod ./ip_vs_mh.ko
sysctl -qw net/ipv4/vs/debug_level=7 || true
ipvsadm -A -t 203.0.113.15:80 -s mh
for i in $(seq 1 $NB); do
ipvsadm -a -t 203.0.113.15:80 -r 10.234.79.$((10+i)):80 -m
done
;;
S*)
ip addr add 10.234.79.$((10 + ${uts#S}))/24 dev eth0
ip route add default via 10.234.79.1
;;
esac
service nginx
# Checking CSH table:
# =dmesg --notime | tac \
# | sed -n '0,/Enter: ip_vs_new_dest/p' \
# | grep CSH | awk '{print $5" "$7}' \
# | sort -n