032c671341fd526c7e4e32cb9cba42217165cf5c
[15.05/openwrt.git] / target / linux / ar71xx / base-files / etc / uci-defaults / 02_network
1 #!/bin/sh
2 #
3 # Copyright (C) 2011 OpenWrt.org
4 #
5
6 [ -e /etc/config/network ] && exit 0
7
8 touch /etc/config/network
9
10 . /lib/functions/uci-defaults.sh
11 . /lib/ar71xx.sh
12
13 ucidef_set_interface_loopback
14
15 board=$(ar71xx_board_name)
16
17 case "$board" in
18 all0315n |\
19 all0258n |\
20 ja76pf2|\
21 ubnt-unifi-outdoor)
22         ucidef_set_interface_lan "eth0 eth1"
23         ;;
24
25 ap132 |\
26 wlr8100)
27         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
28         ucidef_add_switch "switch0" "1" "1"
29         ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
30         ucidef_add_switch_vlan "switch0" "2" "0t 1"
31         ;;
32
33 esr1750 |\
34 epg5000)
35         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
36         ucidef_add_switch "switch0" "1" "1"
37         ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
38         ucidef_add_switch_vlan "switch0" "2" "0t 5"
39         ;;
40
41 ap136-010)
42         ucidef_set_interfaces_lan_wan "eth0" "eth1"
43         ucidef_add_switch "switch0" "1" "1"
44         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
45         ucidef_add_switch_vlan "switch0" "2" "5 6"
46         ;;
47
48 ap136-020 |\
49 ap135-020 |\
50 tl-wr1043nd-v2 |\
51 wzr-450hp2)
52         ucidef_set_interfaces_lan_wan "eth1" "eth0"
53         ucidef_add_switch "switch0" "1" "1"
54         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
55         ucidef_add_switch_vlan "switch0" "2" "5 6"
56         ;;
57
58 archer-c5 |\
59 archer-c7 |\
60 dw33d |\
61 tl-wdr4900-v2)
62         ucidef_set_interfaces_lan_wan "eth1" "eth0"
63         ucidef_add_switch "switch0" "1" "1"
64         ucidef_add_switch_vlan "switch0" "1" "0 2 3 4 5"
65         ucidef_add_switch_vlan "switch0" "2" "1 6"
66         ;;
67
68 bsb)
69         ucidef_set_interfaces_lan_wan "eth1" "eth0"
70         ucidef_add_switch "switch0" "1" "1"
71         ucidef_add_switch_vlan "switch0" "1" "0 1 3"
72         ucidef_set_interface_wlan
73         ;;
74
75 cpe510)
76         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
77         ucidef_add_switch "switch0" "1" "1"
78         ucidef_add_switch_vlan "switch0" "1" "0t 5"
79         ucidef_add_switch_vlan "switch0" "2" "0t 4"
80         ;;
81
82 db120 |\
83 rb-2011l | \
84 rb-2011uas |\
85 rb-2011uias |\
86 rb-2011uas-2hnd|\
87 rb-2011uias-2hnd)
88         ucidef_set_interfaces_lan_wan "eth0.1 eth1" "eth0.2"
89         ucidef_add_switch "switch0" "1" "1"
90         ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
91         ucidef_add_switch_vlan "switch0" "2" "0t 1"
92         ucidef_add_switch "switch1" "1" "1"
93         ucidef_add_switch_vlan "switch1" "1" "0 1 2 3 4 5"
94
95         case "$board" in
96         rb-2011uas* | rb-2011uias | rb-2011uias-2hnd)
97                 ucidef_set_interface_raw "sfp" "eth0.3"
98                 ucidef_add_switch_vlan "switch0" "3" "0t 6"
99                 ;;
100         esac
101         ;;
102
103 dir-825-b1|\
104 tew-673gru)
105         ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
106         ucidef_add_switch "switch0" "1" "1"
107         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
108         ;;
109
110 f9k1115v2)
111         ucidef_set_interfaces_lan_wan "eth1" "eth0"
112         ucidef_add_switch "switch0" "1" "1"
113         ucidef_add_switch_vlan "switch0" "1" "2 3 4 5 6"
114         ucidef_add_switch_vlan "switch0" "2" "0 1"
115         ;;
116
117 nbg460n_550n_550nh)
118         ucidef_set_interfaces_lan_wan "eth0" "eth1"
119         ucidef_add_switch "switch0" "1" "1"
120         ucidef_add_switch_vlan "switch0" "0" "0 1 2 3 5"
121         ;;
122
123 nbg6716)
124         ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
125         ucidef_add_switch "switch0" "1" "1"
126         ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
127         ucidef_add_switch_vlan "switch0" "2" "5 6"
128         ;;
129
130 rb-433 |\
131 rb-433u)
132         ucidef_set_interfaces_lan_wan "eth1" "eth0"
133         ucidef_add_switch "switch0" "1" "1"
134         ucidef_add_switch_vlan "switch0" "1" "1 2 5"
135         ;;
136
137 rb-435g)
138         ucidef_set_interfaces_lan_wan "eth1" "eth0"
139         ucidef_add_switch "switch0" "1" "1"
140         ucidef_add_switch_vlan "switch0" "1" "0 1 2"
141         ;;
142
143 rb-450)
144         ucidef_set_interfaces_lan_wan "eth1" "eth0"
145         ucidef_add_switch "switch0" "1" "1"
146         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5"
147         ;;
148
149 rb-450g |\
150 routerstation-pro)
151         ucidef_set_interfaces_lan_wan "eth1" "eth0"
152         ucidef_add_switch "switch0" "1" "1"
153         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
154         ;;
155
156 ap136 |\
157 rb-750gl |\
158 rb-751g |\
159 rb-951g-2hnd |\
160 wzr-hp-g450h)
161         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
162         ucidef_add_switch "switch0" "1" "1"
163         ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
164         ucidef_add_switch_vlan "switch0" "2" "0t 1"
165         ;;
166
167 rb-951ui-2hnd)
168         ucidef_set_interfaces_lan_wan "eth1" "eth0"
169         ;;
170
171 rb-493g)
172         ucidef_set_interfaces_lan_wan "eth0 eth1.1" "eth1.2"
173         ucidef_add_switch "switch0" "1" "1"
174         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
175         ucidef_add_switch "switch1" "1" "1"
176         ucidef_add_switch_vlan "switch1" "1" "0t 1 2 3 4"
177         ucidef_add_switch_vlan "switch1" "2" "0t 5"
178         ;;
179
180 wzr-hp-g300nh2 |\
181 pb92 |\
182 ap113)
183         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
184         ucidef_add_switch "switch0" "1" "1"
185         ucidef_add_switch_vlan "switch0" "1" "0t 1 3 4 5"
186         ucidef_add_switch_vlan "switch0" "2" "0t 2"
187         ;;
188
189 el-m150)
190         ucidef_set_interfaces_lan_wan "eth1" "eth0"
191         ucidef_add_switch "switch0" "1" "1"
192         ucidef_add_switch_vlan "switch0" "1" "0 1 3"
193         ;;
194
195 tl-wdr4300|\
196 tl-wr1041n-v2)
197         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
198         ucidef_add_switch "switch0" "1" "1"
199         ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
200         ucidef_add_switch_vlan "switch0" "2" "0t 1"
201         ;;
202
203 tl-wr1043nd)
204         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
205         ucidef_add_switch "switch0" "1" "1"
206         ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
207         ucidef_add_switch_vlan "switch0" "2" "0 5t"
208         ;;
209
210 tl-wr2543n)
211         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
212         ucidef_add_switch "switch0" "1" "1"
213         ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 9t"
214         ucidef_add_switch_vlan "switch0" "2" "0 9t"
215         ;;
216
217 tl-wr841n-v1|\
218 tl-wr941nd)
219         ucidef_set_interface_raw "eth" "eth0"
220         ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
221         ;;
222
223 r6100 |\
224 smart-300 |\
225 dir-615-i1 |\
226 tl-mr3420-v2 |\
227 tl-wr841n-v8 |\
228 tl-wr842n-v2 |\
229 tl-wr941nd-v5 |\
230 tl-wr941nd-v6 |\
231 wnr2000-v3 |\
232 wnr2000-v4 |\
233 wnr2200 |\
234 wnr612-v2 |\
235 wnr1000-v2 |\
236 wpn824n)
237         ucidef_set_interfaces_lan_wan "eth1" "eth0"
238         ucidef_add_switch "switch0" "1" "1"
239         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
240         ;;
241
242 uap-pro)
243         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
244         ucidef_add_switch "switch0" "1" "1"
245         ucidef_add_switch_vlan "switch0" "1" "0t 1"
246         ucidef_add_switch_vlan "switch0" "2" "0t 2"
247         ;;
248
249 nanostation-m-xw)
250         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
251         ucidef_add_switch "switch0" "1" "1"
252         ucidef_add_switch_vlan "switch0" "1" "0t 5"
253         ucidef_add_switch_vlan "switch0" "2" "0t 1"
254         ;;
255
256 wrt160nl)
257         ucidef_set_interfaces_lan_wan "eth0" "eth1"
258         ucidef_add_switch "switch0" "1" "1"
259         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4 5"
260         ;;
261
262 wzr-hp-g300nh)
263         ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
264         ucidef_add_switch "switch0" "1" "1"
265         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
266         ;;
267
268 dgl-5500-a1 |\
269 dir-825-c1)
270         local mac
271         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
272         ucidef_add_switch "switch0" "1" "1"
273         ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
274         ucidef_add_switch_vlan "switch0" "2" "0t 5"
275         mac=$(mtd_get_mac_ascii nvram "wan_mac")
276         [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
277         ;;
278
279 mynet-n750)
280         local mac
281         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
282         ucidef_add_switch "switch0" "1" "1"
283         ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
284         ucidef_add_switch_vlan "switch0" "2" "0t 5"
285         mac=$(mtd_get_mac_ascii devdata "wanmac")
286         [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
287         ;;
288
289 onion-omega)
290         ucidef_set_interface_lan "wlan0"
291         ;;
292
293 dhp-1565-a1 |\
294 dir-835-a1 |\
295 wndr3700v4 | \
296 wndr4300)
297         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
298         ucidef_add_switch "switch0" "1" "1"
299         ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
300         ucidef_add_switch_vlan "switch0" "2" "0t 5"
301         mac_lan=$(mtd_get_mac_binary caldata 0)
302         [ -n "$mac_lan" ] && ucidef_set_interface_macaddr "lan" "$mac_lan"
303         mac_wan=$(mtd_get_mac_binary caldata 6)
304         [ -n "$mac_wan" ] && ucidef_set_interface_macaddr "wan" "$mac_wan"
305         ;;
306
307 esr900)
308         local mac
309         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
310         ucidef_add_switch "switch0" "1" "1"
311         ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
312         ucidef_add_switch_vlan "switch0" "2" "0t 5"
313         mac=$(mtd_get_mac_ascii u-boot-env "wanaddr")
314         [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
315         ;;
316
317 dlan-pro-500-wp)
318         ucidef_set_interface_lan "eth0 eth1"
319         ;;
320
321 dlan-pro-1200-ac)
322         ucidef_set_interface_lan "eth0"
323         ucidef_add_switch "switch0" "1" "0"
324         ucidef_add_switch_vlan "switch0" "0" "0 2 3 4"
325         ;;
326
327 alfa-ap120c |\
328 all0305 |\
329 antminer-s1 |\
330 antminer-s3 |\
331 aw-nr580 |\
332 bullet-m |\
333 cap4200ag |\
334 eap300v2 |\
335 eap7660d |\
336 el-mini |\
337 loco-m-xw |\
338 mr1750 |\
339 mr1750v2 |\
340 mr600 |\
341 mr600v2 |\
342 mr900 |\
343 mr900v2 |\
344 rb-411 |\
345 rb-911g-2hpnd |\
346 rb-911g-5hpacd |\
347 rb-911g-5hpnd |\
348 rb-912uag-2hpnd |\
349 rb-912uag-5hpnd |\
350 rb-sxt2n |\
351 rb-sxt5n |\
352 rocket-m-xw |\
353 tl-mr10u |\
354 tl-mr11u |\
355 tl-mr12u |\
356 tl-mr13u |\
357 tl-mr3020 |\
358 tl-mr3040 |\
359 tl-mr3040-v2 |\
360 tl-wa701nd-v2 |\
361 tl-wa7210n-v2 |\
362 tl-wa750re |\
363 tl-wa850re |\
364 tl-wa830re-v2 |\
365 tl-wa801nd-v2 |\
366 tl-wa901nd |\
367 tl-wa901nd-v2 |\
368 tl-wa901nd-v3 |\
369 tl-wa901nd-v4 |\
370 tl-wr703n |\
371 tube2h |\
372 wndap360 |\
373 mynet-rext |\
374 wp543)
375         ucidef_set_interface_lan "eth0"
376         ;;
377
378 dir-505-a1)
379         ucidef_set_interface_lan "eth1"
380         ;;
381
382 alfa-ap96 |\
383 alfa-nx |\
384 ap83 |\
385 gl-inet |\
386 jwap003 |\
387 pb42 |\
388 pb44 |\
389 routerstation|\
390 tl-wr710n |\
391 tl-wr720n-v3|\
392 wpe72)
393         ucidef_set_interfaces_lan_wan "eth1" "eth0"
394         ;;
395
396 wpj344)
397         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
398         ucidef_add_switch "switch0" "1" "1"
399         ucidef_add_switch_vlan "switch0" "1" "0t 3"
400         ucidef_add_switch_vlan "switch0" "2" "0t 2"
401         ;;
402
403 wpj531)
404         ucidef_set_interfaces_lan_wan "eth0" "eth1"
405         ;;
406
407 wpj558)
408         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
409         ucidef_add_switch "switch0" "1" "1"
410         ucidef_add_switch_vlan "switch0" "1" "5 6t"
411         ucidef_add_switch_vlan "switch0" "2" "1 6t"
412         ;;
413
414 ap121 |\
415 ap121-mini |\
416 ap96 |\
417 airrouter |\
418 dir-600-a1 |\
419 dir-615-c1 |\
420 dir-615-e1 |\
421 dir-615-e4 |\
422 hiwifi-hc6361 |\
423 ja76pf |\
424 mc-mac1200r|\
425 minibox-v1 |\
426 mynet-n600 |\
427 oolite |\
428 qihoo-c301 |\
429 rb-750 |\
430 rb-751 |\
431 tew-632brp |\
432 tew-712br |\
433 tew-732br |\
434 tl-mr3220 |\
435 tl-mr3220-v2 |\
436 tl-mr3420 |\
437 tl-wdr3500 |\
438 tl-wr741nd |\
439 tl-wr741nd-v4 |\
440 tl-wr841n-v7 |\
441 tl-wr841n-v9 |\
442 tl-wr841n-v11 |\
443 whr-g301n |\
444 whr-hp-g300n |\
445 whr-hp-gn |\
446 wzr-hp-ag300h)
447         ucidef_set_interfaces_lan_wan "eth0" "eth1"
448         ucidef_add_switch "switch0" "1" "1"
449         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
450         ;;
451
452 wzr-hp-g450h)
453         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
454         ucidef_add_switch "switch0" "1" "1"
455         ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
456         ucidef_add_switch_vlan "switch0" "2" "0t 1"
457         ;;
458
459 ew-dorin)
460         ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
461         ucidef_add_switch "switch0" "1" "1"
462         ucidef_add_switch_vlan "switch0" "1" "0t 1 2"
463         ucidef_add_switch_vlan "switch0" "2" "0t 3"
464         ;;
465
466 ew-dorin-router)
467         ucidef_set_interfaces_lan_wan "eth0" "eth1"
468         ucidef_add_switch "switch0" "1" "1"
469         ucidef_add_switch_vlan "switch0" "1" "0 2 3"
470         ;;
471
472 wndr3700)
473         ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
474         ucidef_add_switch "switch0" "1" "1"
475         ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
476         # Blinkrate: 0=43ms; 1=84ms; 2=120ms; 3=170ms; 4=340ms; 5=670ms
477         uci set network.@switch[-1].blinkrate='2'
478
479         ucidef_add_switch_port "switch0" "1"
480         # Port 1 controls the GREEN configuration of LEDs for
481         # the switch and the section does not correspond to a real
482         # switch port.
483         #
484         # 0=LED off; 1=Collision/FDX; 2=Link/activity; 3=1000 Mb/s;
485         # 4=100 Mb/s; 5=10 Mb/s; 6=1000 Mb/s+activity; 7=100 Mb/s+activity;
486         # 8=10 Mb/s+activity; 9=10/100 Mb/s+activity; 10: Fiber;
487         # 11: Fault; 12: Link/activity(tx); 13: Link/activity(rx);
488         # 14: Link (master); 15: separate register
489         uci set network.@switch_port[-1].led='6'
490
491         ucidef_add_switch_port "switch0" "2"
492         # Port 2 controls the ORANGE configuration of LEDs for
493         # the switch and the section does not correspond to a real
494         # switch port.
495         #
496         # See the key above for switch port 1 for the meaning of the
497         # 'led' setting below.
498         uci set network.@switch_port[-1].led='9'
499
500         ucidef_add_switch_port "switch0" "5"
501         # Port 5 controls the configuration of the WAN LED and the
502         # section does not correspond to a real switch port.
503         #
504         # To toggle the use of green or orange LEDs for the WAN port,
505         # see the LED setting for wndr3700:green:wan in /etc/config/system.
506         #
507         # See the key above for switch port 1 for the meaning of the
508         # 'led' setting below.
509         uci set network.@switch_port[-1].led='2'
510         ;;
511
512 *)
513         ucidef_set_interfaces_lan_wan "eth0" "eth1"
514         ;;
515 esac
516
517 uci commit network
518
519 exit 0