a2b27625d1abee5d0ffd852c9199213062dbab99
[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 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 ap136-010)
34 ucidef_set_interfaces_lan_wan "eth0" "eth1"
35 ucidef_add_switch "switch0" "1" "1"
36 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
37 ucidef_add_switch_vlan "switch0" "2" "5 6"
38 ;;
39
40 ap136-020 |\
41 ap135-020 |\
42 tl-wr1043nd-v2)
43 ucidef_set_interfaces_lan_wan "eth1" "eth0"
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 archer-c7 |\
50 tl-wdr4900-v2)
51 ucidef_set_interfaces_lan_wan "eth1" "eth0"
52 ucidef_add_switch "switch0" "1" "1"
53 ucidef_add_switch_vlan "switch0" "1" "0 2 3 4 5"
54 ucidef_add_switch_vlan "switch0" "2" "1 6"
55 ;;
56
57 db120 |\
58 rb-2011l | \
59 rb-2011uas |\
60 rb-2011uas-2hnd)
61 ucidef_set_interfaces_lan_wan "eth0.1 eth1" "eth0.2"
62 ucidef_add_switch "switch0" "1" "1"
63 ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
64 ucidef_add_switch_vlan "switch0" "2" "0t 1"
65 ucidef_add_switch "switch1" "1" "1"
66 ucidef_add_switch_vlan "switch1" "1" "0 1 2 3 4 5"
67
68 case "$board" in
69 rb-2011uas*)
70 ucidef_set_interface_raw "sfp" "eth0.3"
71 ucidef_add_switch_vlan "switch0" "3" "0t 6"
72 ;;
73 esac
74 ;;
75
76 dir-825-b1|\
77 tew-673gru)
78 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
79 ucidef_add_switch "switch0" "1" "1"
80 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
81 ;;
82
83 nbg460n_550n_550nh)
84 ucidef_set_interfaces_lan_wan "eth0" "eth1"
85 ucidef_add_switch "switch0" "1" "1"
86 ucidef_add_switch_vlan "switch0" "0" "0 1 2 3 5"
87 ;;
88
89 nbg6716)
90 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
91 ucidef_add_switch "switch0" "1" "1"
92 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
93 ucidef_add_switch_vlan "switch0" "2" "5 6"
94 ;;
95
96 rb-433 |\
97 rb-433u)
98 ucidef_set_interfaces_lan_wan "eth1" "eth0"
99 ucidef_add_switch "switch0" "1" "1"
100 ucidef_add_switch_vlan "switch0" "1" "1 2 5"
101 ;;
102
103 rb-435g)
104 ucidef_set_interfaces_lan_wan "eth1" "eth0"
105 ucidef_add_switch "switch0" "1" "1"
106 ucidef_add_switch_vlan "switch0" "1" "0 1 2"
107 ;;
108
109 rb-450)
110 ucidef_set_interfaces_lan_wan "eth1" "eth0"
111 ucidef_add_switch "switch0" "1" "1"
112 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5"
113 ;;
114
115 rb-450g |\
116 routerstation-pro)
117 ucidef_set_interfaces_lan_wan "eth1" "eth0"
118 ucidef_add_switch "switch0" "1" "1"
119 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
120 ;;
121
122 ap136 |\
123 rb-750gl |\
124 rb-751g |\
125 rb-951g-2hnd |\
126 wzr-hp-g450h)
127 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
128 ucidef_add_switch "switch0" "1" "1"
129 ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
130 ucidef_add_switch_vlan "switch0" "2" "0t 1"
131 ;;
132
133 rb-951ui-2hnd)
134 ucidef_set_interfaces_lan_wan "eth1" "eth0"
135 ;;
136
137 rb-493g)
138 ucidef_set_interfaces_lan_wan "eth0 eth1.1" "eth1.2"
139 ucidef_add_switch "switch0" "1" "1"
140 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
141 ucidef_add_switch "switch1" "1" "1"
142 ucidef_add_switch_vlan "switch1" "1" "0t 1 2 3 4"
143 ucidef_add_switch_vlan "switch1" "2" "0t 5"
144 ;;
145
146 wzr-hp-g300nh2 |\
147 pb92 |\
148 ap113)
149 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
150 ucidef_add_switch "switch0" "1" "1"
151 ucidef_add_switch_vlan "switch0" "1" "0t 1 3 4 5"
152 ucidef_add_switch_vlan "switch0" "2" "0t 2"
153 ;;
154
155 tl-wdr4300|\
156 tl-wr1041n-v2)
157 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
158 ucidef_add_switch "switch0" "1" "1"
159 ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
160 ucidef_add_switch_vlan "switch0" "2" "0t 1"
161 ;;
162
163 tl-wr1043nd)
164 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
165 ucidef_add_switch "switch0" "1" "1"
166 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 5t"
167 ucidef_add_switch_vlan "switch0" "2" "0 5t"
168 ;;
169
170 tl-wr2543n)
171 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
172 ucidef_add_switch "switch0" "1" "1"
173 ucidef_add_switch_vlan "switch0" "1" "1 2 3 4 9t"
174 ucidef_add_switch_vlan "switch0" "2" "0 9t"
175 ;;
176
177 tl-wr841n-v1|\
178 tl-wr941nd)
179 ucidef_set_interface_raw "eth" "eth0"
180 ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
181 ;;
182
183 tl-mr3420-v2 |\
184 tl-wr841n-v8 |\
185 tl-wr842n-v2 |\
186 wnr2000-v3 |\
187 wnr2200 |\
188 wnr612-v2)
189 ucidef_set_interfaces_lan_wan "eth1" "eth0"
190 ucidef_add_switch "switch0" "1" "1"
191 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
192 ;;
193
194 uap-pro)
195 ucidef_set_interface_lan "eth0"
196 ucidef_add_switch "switch0" "1" "1"
197 ucidef_add_switch_vlan "switch0" "1" "0 1 2"
198 ;;
199
200 wrt160nl)
201 ucidef_set_interfaces_lan_wan "eth0" "eth1"
202 ucidef_add_switch "switch0" "1" "1"
203 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4 5"
204 ;;
205
206 wzr-hp-g300nh)
207 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
208 ucidef_add_switch "switch0" "1" "1"
209 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
210 ;;
211
212 dir-825-c1)
213 local mac
214 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
215 ucidef_add_switch "switch0" "1" "1"
216 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
217 ucidef_add_switch_vlan "switch0" "2" "0t 5"
218 mac=$(mtd_get_mac_ascii nvram "^wan_mac")
219 [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
220 ;;
221
222 mynet-n750)
223 local mac
224 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
225 ucidef_add_switch "switch0" "1" "1"
226 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
227 ucidef_add_switch_vlan "switch0" "2" "0t 5"
228 mac=$(mtd_get_mac_ascii devdata "wanmac")
229 [ -n "$mac" ] && ucidef_set_interface_macaddr "wan" "$mac"
230 ;;
231
232 dir-835-a1 |\
233 wndr4300)
234 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
235 ucidef_add_switch "switch0" "1" "1"
236 ucidef_add_switch_vlan "switch0" "1" "0t 1 2 3 4"
237 ucidef_add_switch_vlan "switch0" "2" "0t 5"
238 mac_lan=$(mtd_get_mac_binary caldata 0)
239 [ -n "$mac_lan" ] && ucidef_set_interface_macaddr "lan" "$mac_lan"
240 mac_wan=$(mtd_get_mac_binary caldata 6)
241 [ -n "$mac_wan" ] && ucidef_set_interface_macaddr "wan" "$mac_wan"
242 ;;
243
244 all0305 |\
245 aw-nr580 |\
246 bullet-m |\
247 cap4200ag |\
248 eap7660d |\
249 mr600 |\
250 mr600v2 |\
251 rb-411 |\
252 tl-mr10u |\
253 tl-mr11u |\
254 tl-mr13u |\
255 tl-mr3020 |\
256 tl-mr3040 |\
257 tl-mr3040-v2 |\
258 tl-wa750re |\
259 tl-wa850re |\
260 tl-wa801nd-v2 |\
261 tl-wa901nd |\
262 tl-wa901nd-v2 |\
263 tl-wa901nd-v3 |\
264 tl-wr703n |\
265 wndap360 |\
266 mynet-rext |\
267 wp543)
268 ucidef_set_interface_lan "eth0"
269 ;;
270
271 dir-505-a1)
272 ucidef_set_interface_lan "eth1"
273 ;;
274
275 alfa-ap96 |\
276 alfa-nx |\
277 ap83 |\
278 jwap003 |\
279 pb42 |\
280 pb44 |\
281 routerstation|\
282 tl-wr710n |\
283 tl-wr720n-v3|\
284 wpe72)
285 ucidef_set_interfaces_lan_wan "eth1" "eth0"
286 ;;
287
288 ap121 |\
289 ap121-mini |\
290 ap96 |\
291 airrouter |\
292 dir-600-a1 |\
293 dir-615-c1 |\
294 dir-615-e1 |\
295 dir-615-e4 |\
296 hiwifi-hc6361 |\
297 ja76pf |\
298 mynet-n600 |\
299 oolite |\
300 rb-750 |\
301 rb-751 |\
302 tew-632brp |\
303 tew-712br |\
304 tl-mr3220 |\
305 tl-mr3220-v2 |\
306 tl-mr3420 |\
307 tl-wdr3500 |\
308 tl-wr741nd |\
309 tl-wr741nd-v4 |\
310 tl-wr841n-v7 |\
311 tl-wr841n-v9 |\
312 whr-g301n |\
313 whr-hp-g300n |\
314 whr-hp-gn |\
315 wzr-hp-ag300h)
316 ucidef_set_interfaces_lan_wan "eth0" "eth1"
317 ucidef_add_switch "switch0" "1" "1"
318 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 4"
319 ;;
320
321 wzr-hp-g450h)
322 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
323 ucidef_add_switch "switch0" "1" "1"
324 ucidef_add_switch_vlan "switch0" "1" "0t 2 3 4 5"
325 ucidef_add_switch_vlan "switch0" "2" "0t 1"
326 ;;
327
328 ew-dorin)
329 ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
330 ucidef_add_switch "switch0" "1" "1"
331 ucidef_add_switch_vlan "switch0" "1" "0t 1 2"
332 ucidef_add_switch_vlan "switch0" "2" "0t 3"
333 ;;
334
335 ew-dorin-router)
336 ucidef_set_interfaces_lan_wan "eth0" "eth1"
337 ucidef_add_switch "switch0" "1" "1"
338 ucidef_add_switch_vlan "switch0" "1" "0 2 3"
339 ;;
340
341 wndr3700)
342 ucidef_set_interfaces_lan_wan "eth0.1" "eth1"
343 ucidef_add_switch "switch0" "1" "1"
344 ucidef_add_switch_vlan "switch0" "1" "0 1 2 3 5t"
345 # Blinkrate: 0=43ms; 1=84ms; 2=120ms; 3=170ms; 4=340ms; 5=670ms
346 uci set network.@switch[-1].blinkrate='2'
347
348 ucidef_add_switch_port "switch0" "1"
349 # Port 1 controls the GREEN configuration of LEDs for
350 # the switch and the section does not correspond to a real
351 # switch port.
352 #
353 # 0=LED off; 1=Collision/FDX; 2=Link/activity; 3=1000 Mb/s;
354 # 4=100 Mb/s; 5=10 Mb/s; 6=1000 Mb/s+activity; 7=100 Mb/s+activity;
355 # 8=10 Mb/s+activity; 9=10/100 Mb/s+activity; 10: Fiber;
356 # 11: Fault; 12: Link/activity(tx); 13: Link/activity(rx);
357 # 14: Link (master); 15: separate register
358 uci set network.@switch_port[-1].led='6'
359
360 ucidef_add_switch_port "switch0" "2"
361 # Port 2 controls the ORANGE configuration of LEDs for
362 # the switch and the section does not correspond to a real
363 # switch port.
364 #
365 # See the key above for switch port 1 for the meaning of the
366 # 'led' setting below.
367 uci set network.@switch_port[-1].led='9'
368
369 ucidef_add_switch_port "switch0" "5"
370 # Port 5 controls the configuration of the WAN LED and the
371 # section does not correspond to a real switch port.
372 #
373 # To toggle the use of green or orange LEDs for the WAN port,
374 # see the LED setting for wndr3700:green:wan in /etc/config/system.
375 #
376 # See the key above for switch port 1 for the meaning of the
377 # 'led' setting below.
378 uci set network.@switch_port[-1].led='2'
379 ;;
380
381 *)
382 ucidef_set_interfaces_lan_wan "eth0" "eth1"
383 ;;
384 esac
385
386 uci commit network
387
388 exit 0