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