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