summaryrefslogtreecommitdiff
path: root/vnet/build.sh
blob: 5354969a910622b548f086fa1170e86cde71955b (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
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh


wire() {
    ip link add $1   \
           type veth \
      peer name $2
}

set -x

# Not using this...
buildhub() {
	wire hub0 ep0
	wire hub1 ep1
	wire hub2 ep2
	wire hub3 ep3
	wire hub4 ep4
	wire hub5 ep5
	wire hub6 ep6
	wire hub7 ep7

	wire hub8 ep8
	wire hub9 ep9
	wire hubA epA
	wire hubB epB
	wire hubC epC
	wire hubD epD
	wire hubE epE
	wire hubF epF

	brctl addbr hub
	brctl addif hub hub0
	brctl addif hub hub1
	brctl addif hub hub2
	brctl addif hub hub3
	brctl addif hub hub4
	brctl addif hub hub5
	brctl addif hub hub6
	brctl addif hub hub7
	brctl addif hub hub8
	brctl addif hub hub9
	brctl addif hub hubA
	brctl addif hub hubB
	brctl addif hub hubC
	brctl addif hub hubD
	brctl addif hub hubE
	brctl addif hub hubF

	ip addr add 222.0.0.1 dev hub
}

# This is simpler...
buildtaps() {
    ip tuntap add ep0 mode tap
    ip tuntap add ep1 mode tap
    ip tuntap add ep2 mode tap
    ip tuntap add ep3 mode tap
    ip tuntap add ep4 mode tap
    ip tuntap add ep5 mode tap
    ip tuntap add ep6 mode tap
    ip tuntap add ep7 mode tap
    ip tuntap add ep8 mode tap
    ip tuntap add ep9 mode tap
    ip tuntap add epA mode tap
    ip tuntap add epB mode tap
    ip tuntap add epC mode tap
    ip tuntap add epD mode tap
    ip tuntap add epE mode tap
    ip tuntap add epF mode tap
}

buildtaps

num=$(ip addr show wlan0 | sed -n '/\s\+inet 192/ s/\s\+inet 192\.168\.[0-9]*\.\([0-9]*\).*$/\1/ p')
num=${num:-88}

ip addr add 80.$num.99.99 dev ep0
ip addr add 81.$num.99.99 dev ep1
ip addr add 82.$num.99.99 dev ep2
ip addr add 83.$num.99.99 dev ep3
ip addr add 84.$num.99.99 dev ep4
ip addr add 85.$num.99.99 dev ep5
ip addr add 86.$num.99.99 dev ep6
ip addr add 87.$num.99.99 dev ep7
ip addr add 88.$num.99.99 dev ep8
ip addr add 89.$num.99.99 dev ep9
ip addr add 90.$num.99.99 dev epA
ip addr add 91.$num.99.99 dev epB
ip addr add 92.$num.99.99 dev epC
ip addr add 93.$num.99.99 dev epD
ip addr add 94.$num.99.99 dev epE
ip addr add 95.$num.99.99 dev epF