forked from imaginator/home-network
-
Notifications
You must be signed in to change notification settings - Fork 0
/
switch02.settings
222 lines (188 loc) · 7.77 KB
/
switch02.settings
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#!/bin/sh
# DLINK DGS 1210-28
# stop after any errors
set -xe
uci import system <<EOF
EOF
uci add system system
uci set system.@system[-1]=system
uci set system.@system[-1].hostname='switch02'
uci set system.@system[-1].zonename='UTC'
uci set system.@system[-1].timezone='UTC'
uci set system.@system[-1].conloglevel='8'
uci set system.@system[-1].klogconloglevel='8'
uci set system.@system[-1].cronloglevel='0'
uci set system.@system[-1].log_ip='10.7.11.1'
uci set system.@system[-1].log_proto='tcp'
uci set system.@system[-1].log_port='514'
uci set system.@system[-1].log_size='128'
uci set system.@system[-1].log_buffer_size='64'
uci set system.@system[-1].log_remote='1'
uci set system.ntp=timeserver
uci set system.ntp.enabled=1
uci add_list system.ntp.server='0.de.pool.ntp.org'
uci add_list system.ntp.server='1.de.pool.ntp.org'
uci add_list system.ntp.server='2.de.pool.ntp.org'
uci set system.@system[-1].location='Falckensteinstrasse 17'
uci set system.@system[-1].latitude='52.497618743398135'
uci set system.@system[-1].longitude='13.441156148912176'
uci commit system
uci import system.watchcat <<EOF
EOF
uci add system watchcat
uci set system.@watchcat[-1]=watchcat
uci set system.@watchcat[-1].mode='ping'
uci set system.@watchcat[-1].forcedelay='300'
uci set system.@watchcat[-1].period='30m'
uci set system.@watchcat[-1].pingperiod='5m'
uci set system.@watchcat[-1].pinghosts='1.1.1.1'
uci commit system.watchcat
uci import dropbear <<EOF
EOF
uci add dropbear dropbear
uci set dropbear.@dropbear[-1]=dropbear
uci set dropbear.@dropbear[-1].Port='22'
uci set dropbear.@dropbear[-1].PasswordAuth='0'
uci set dropbear.@dropbear[-1].RootPasswordAuth='0'
uci commit dropbear
cat <<'EOF' > /etc/dropbear/authorized_keys
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHwK3f7YB4qmDKgnZ6yKaQlLEdDAFaVbNREiE2gyHwSN [email protected]
EOF
chmod 0600 /etc/dropbear/authorized_keys
uci import network <<EOF
EOF
uci set network.loopback=interface
uci set network.loopback.device='lo'
uci set network.loopback.proto='static'
uci set network.loopback.ipaddr='127.0.0.1'
uci set network.loopback.netmask='255.0.0.0'
# begin Default access
uci set network.lan=interface
uci set network.lan.proto='static'
uci set network.lan.device='lan1'
uci set network.lan.ipaddr='192.168.1.1'
uci set network.lan.netmask='255.255.255.0'
# end Default access
uci add network device
uci set network.@device[-1].type='bridge'
uci set network.@device[-1].name='switch'
# lan1 left for emergency access
uci add_list network.@device[-1].ports='lan2'
uci add_list network.@device[-1].ports='lan3'
uci add_list network.@device[-1].ports='lan4'
uci add_list network.@device[-1].ports='lan5'
uci add_list network.@device[-1].ports='lan6'
uci add_list network.@device[-1].ports='lan7'
uci add_list network.@device[-1].ports='lan8'
uci add_list network.@device[-1].ports='lan9'
uci add_list network.@device[-1].ports='lan10'
uci add_list network.@device[-1].ports='lan11'
uci add_list network.@device[-1].ports='lan12'
uci add_list network.@device[-1].ports='lan13'
uci add_list network.@device[-1].ports='lan14'
uci add_list network.@device[-1].ports='lan15'
uci add_list network.@device[-1].ports='lan16'
uci add_list network.@device[-1].ports='lan17'
uci add_list network.@device[-1].ports='lan18'
uci add_list network.@device[-1].ports='lan19'
uci add_list network.@device[-1].ports='lan20'
uci add_list network.@device[-1].ports='lan21'
uci add_list network.@device[-1].ports='lan22'
uci add_list network.@device[-1].ports='lan23'
uci add_list network.@device[-1].ports='lan24'
uci add_list network.@device[-1].ports='lan25'
uci add_list network.@device[-1].ports='lan26'
uci add_list network.@device[-1].ports='lan27'
uci add_list network.@device[-1].ports='lan28'
# vlan: trusted
uci add network bridge-vlan
uci set network.@bridge-vlan[-1].device='switch'
uci set network.@bridge-vlan[-1].vlan='2'
uci add_list network.@bridge-vlan[-1].ports='lan2'
uci add_list network.@bridge-vlan[-1].ports='lan3'
uci add_list network.@bridge-vlan[-1].ports='lan4'
uci add_list network.@bridge-vlan[-1].ports='lan5'
uci add_list network.@bridge-vlan[-1].ports='lan6'
uci add_list network.@bridge-vlan[-1].ports='lan7'
uci add_list network.@bridge-vlan[-1].ports='lan8'
uci add_list network.@bridge-vlan[-1].ports='lan27:t'
uci add_list network.@bridge-vlan[-1].ports='lan28:t'
# vlan: notrust
uci add network bridge-vlan
uci set network.@bridge-vlan[-1].device='switch'
uci set network.@bridge-vlan[-1].vlan='3'
uci add_list network.@bridge-vlan[-1].ports='lan9'
uci add_list network.@bridge-vlan[-1].ports='lan10'
uci add_list network.@bridge-vlan[-1].ports='lan11'
uci add_list network.@bridge-vlan[-1].ports='lan12'
uci add_list network.@bridge-vlan[-1].ports='lan13'
uci add_list network.@bridge-vlan[-1].ports='lan14'
uci add_list network.@bridge-vlan[-1].ports='lan15'
uci add_list network.@bridge-vlan[-1].ports='lan16'
uci add_list network.@bridge-vlan[-1].ports='lan27:t'
uci add_list network.@bridge-vlan[-1].ports='lan28:t'
# vlan: wan
uci add network bridge-vlan
uci set network.@bridge-vlan[-1].device='switch'
uci set network.@bridge-vlan[-1].vlan='4'
uci add_list network.@bridge-vlan[-1].ports='lan17'
uci add_list network.@bridge-vlan[-1].ports='lan18'
uci add_list network.@bridge-vlan[-1].ports='lan19'
uci add_list network.@bridge-vlan[-1].ports='lan27:t'
uci add_list network.@bridge-vlan[-1].ports='lan28:t'
# vlan: iot
uci add network bridge-vlan
uci set network.@bridge-vlan[-1].device='switch'
uci set network.@bridge-vlan[-1].vlan='5'
uci add_list network.@bridge-vlan[-1].ports='lan27:t'
uci add_list network.@bridge-vlan[-1].ports='lan28:t'
uci set network.trusted=interface
uci set network.trusted.proto='static'
uci set network.trusted.ipaddr='10.7.11.3'
uci set network.trusted.netmask='255.255.255.0'
uci set network.trusted.device='switch.2'
uci set network.trusted.gateway='10.7.11.5'
uci set network.trusted.broadcast='10.7.11.255'
uci add_list network.trusted.dns='10.7.11.5'
uci commit network
uci set luci.sauth.sessiontime="36000000"
uci commit luci
uci import prometheus-node-exporter-lua<<EOF
EOF
uci set prometheus-node-exporter-lua.main=prometheus-node-exporter-lua
uci set prometheus-node-exporter-lua.main.listen_interface='trusted'
uci set prometheus-node-exporter-lua.main.listen_port='9100'
uci commit prometheus-node-exporter-lua
service prometheus-node-exporter-lua enable || true
uci import firewall <<EOF
EOF
uci add firewall defaults
uci set firewall.@defaults[-1]=defaults
uci set firewall.@defaults[-1].input='ACCEPT'
uci set firewall.@defaults[-1].output='ACCEPT'
uci set firewall.@defaults[-1].forward='ACCEPT'
uci commit firewall.@defaults[-1]
###############################################################################
# never lock ourselves out
###############################################################################
uci add firewall rule
uci set firewall.@rule[-1]=rule
uci set firewall.@rule[-1].name='ssh to router'
uci set firewall.@rule[-1].src='*'
uci set firewall.@rule[-1].dest_port='22'
uci set firewall.@rule[-1].proto='tcp'
uci set firewall.@rule[-1].family='any'
uci set firewall.@rule[-1].target='ACCEPT'
uci commit firewall.@rule[-1]
uci add firewall rule
uci set firewall.@rule[-1]=rule
uci set firewall.@rule[-1].name='Allow-Ping'
uci set firewall.@rule[-1].src='*'
uci set firewall.@rule[-1].family='any'
uci set firewall.@rule[-1].proto='icmp'
uci set firewall.@rule[-1].icmp_type='echo-request'
uci set firewall.@rule[-1].target='ACCEPT'
uci commit firewall.@rule[-1]
service firewall enable || true
echo -e "All done with writing.\nRebooting..."
reboot