This repository was archived by the owner on May 15, 2025. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathnetwork.sh
More file actions
executable file
·84 lines (69 loc) · 2.15 KB
/
Copy pathnetwork.sh
File metadata and controls
executable file
·84 lines (69 loc) · 2.15 KB
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
#!/usr/bin/env bash
set -eux
sysctl -w net.ipv4.conf.all.forwarding=1 \
net.ipv4.conf.default.forwarding=1 \
net.ipv6.conf.all.forwarding=1 \
net.ipv6.conf.default.forwarding=1
ip netns delete router >/dev/null 2>&1 || true
ip netns delete nas >/dev/null 2>&1 || true
ip netns delete pc >/dev/null 2>&1 || true
ip link delete router >/dev/null 2>&1 || true
ip link delete br0 >/dev/null 2>&1 || true
ip netns add pc
ip netns add router
ip netns add nas
ip netns exec pc bash -x -c '
ip link set lo up
ip link add eth0 type veth peer name pc
ip link set eth0 up
ip addr add 192.168.42.2/24 dev eth0
ip addr add fd42::2/64 dev eth0
ip route add default via 192.168.42.1 dev eth0
ip route add default via fe80::1 dev eth0
ip link set pc netns router
'
ip netns exec nas bash -x -c '
ip link set lo up
ip link add eth0 type veth peer name nas
ip link set eth0 up
ip addr add 192.168.42.3/24 dev eth0
ip addr add fd42::3/64 dev eth0
ip route add default via 192.168.42.1 dev eth0
ip route add default via fe80::1 dev eth0
ip link set nas netns router
'
ip netns exec router bash -x -c '
ip link set lo up
sysctl -w net.ipv4.conf.all.forwarding=1 \
net.ipv4.conf.default.forwarding=1 \
net.ipv6.conf.all.forwarding=1 \
net.ipv6.conf.default.forwarding=1
ip link add lan type bridge
ip link set dev pc master lan
ip link set dev nas master lan
ip link set pc up
ip link set nas up
ip link set lan up
ip addr add 192.168.42.1/24 dev lan
ip addr add fe80::1/24 dev lan
ip addr add fd42::1/64 dev lan
ip link add wan type veth peer name router
ip link set wan up
# xxx hopefully free
ip addr add 172.22.99.249/24 dev wan
ip addr add fe80::92/65 dev wan
ip route add default dev wan
ip -6 route add default dev wan
ip link set router netns 1
'
ip link add br0 type bridge
ip link set router master br0
ip link set router up
ip link set br0 up
ip link set enp0s25 master br0
ip route a fd42::1/64 via fe80::92 dev br0
ip addr add fd43::1/64 dev br0
ip a flush dev enp0s25
#ip a a 172.22.99.128/24 dev br0
#ip r a default via 172.22.99.4 dev br0 metric 256
#ip route add 192.168.42.0/24 via 172.22.99.249 dev br0