041d5f018f91985f4083c84bbf5692c6e1c729d9
[openwrt.git] / target / linux / ar71xx / base-files / etc / uci-defaults / network
1 #!/bin/sh
2 #
3 # Copyright (C) 2011 OpenWrt.org
4 #
5
6 set_interface_loopback() {
7 uci batch <<EOF
8 set network.loopback='interface'
9 set network.loopback.ifname='lo'
10 set network.loopback.proto='static'
11 set network.loopback.ipaddr='127.0.0.1'
12 set network.loopback.netmask='255.0.0.0'
13 EOF
14 }
15
16 set_interface_raw() {
17 local cfg=$1
18 local ifname=$2
19
20 uci batch <<EOF
21 set network.$cfg='interface'
22 set network.$cfg.ifname='$ifname'
23 set network.$cfg.proto='none'
24 EOF
25 }
26
27 set_interface_lan() {
28 local ifname=$1
29
30 uci batch <<EOF
31 set network.lan='interface'
32 set network.lan.ifname='$ifname'
33 set network.lan.type='bridge'
34 set network.lan.proto='static'
35 set network.lan.ipaddr='192.168.1.1'
36 set network.lan.netmask='255.255.255.0'
37 EOF
38 }
39
40 set_interface_wan() {
41 local ifname=$1
42
43 uci batch <<EOF
44 set network.wan='interface'
45 set network.wan.ifname='$ifname'
46 set network.wan.proto='dhcp'
47 EOF
48 }
49
50 set_interfaces_lan_wan() {
51 local lan_ifname=$1
52 local wan_ifname=$2
53
54 set_interface_lan "$lan_ifname"
55 set_interface_wan "$wan_ifname"
56 }
57
58 add_switch() {
59 local name=$1
60 local reset=$2
61 local enable=$3
62 uci batch <<EOF
63 add network switch
64 set network.@switch[-1].name='$name'
65 set network.@switch[-1].reset='$reset'
66 set network.@switch[-1].enable_vlan='$enable'
67 EOF
68 }
69
70 add_switch_vlan() {
71 local device=$1
72 local vlan=$2
73 local ports=$3
74 uci batch <<EOF
75 add network switch_vlan
76 set network.@switch_vlan[-1].device='$device'
77 set network.@switch_vlan[-1].vlan='$vlan'
78 set network.@switch_vlan[-1].ports='$ports'
79 EOF
80 }
81
82 [ -e /etc/config/network ] && exit 0
83
84 touch /etc/config/network
85
86 set_interface_loopback
87
88 . /lib/ar71xx.sh
89
90 board=$(ar71xx_board_name)
91
92 case "$board" in
93 all0258n)
94 set_interface_lan "eth0 eth1"
95 ;;
96
97 dir-825-b1)
98 set_interfaces_lan_wan "eth0.1" "eth1"
99 add_switch "rtl8366s" "1" "1"
100 add_switch_vlan "rtl8366s" "1" "0 1 2 3 5t"
101 ;;
102
103 nbg460n_550n_550nh)
104 set_interfaces_lan_wan "eth0" "eth1"
105 add_switch "rtl8366s" "1" "1"
106 add_switch_vlan "rtl8366s" "0" "0 1 2 3 5"
107 ;;
108
109 rb-433 |\
110 rb-433u)
111 set_interfaces_lan_wan "eth1" "eth0"
112 add_switch "switch0" "1" "1"
113 add_switch_vlan "switch0" "1" "1 2 5"
114 ;;
115
116 rb-450)
117 set_interfaces_lan_wan "eth1" "eth0"
118 add_switch "eth1" "1" "1"
119 add_switch_vlan "eth1" "1" "0 1 2 3 5"
120 ;;
121
122 rb-450g |\
123 routerstation-pro)
124 set_interfaces_lan_wan "eth1" "eth0"
125 add_switch "switch0" "1" "1"
126 add_switch_vlan "switch0" "1" "0 1 2 3 4"
127 ;;
128
129 rb-493g)
130 set_interfaces_lan_wan "eth0 eth1.1" "eth1.2"
131 add_switch "switch0" "1" "1"
132 add_switch_vlan "switch0" "1" "0 1 2 3 4"
133 add_switch "switch1" "1" "1"
134 add_switch_vlan "switch1" "1" "0t 1 2 3 4"
135 add_switch_vlan "switch1" "2" "0t 5"
136 ;;
137
138 pb92)
139 set_interfaces_lan_wan "eth0.1" "eth0.2"
140 add_switch "eth0" "1" "1"
141 add_switch_vlan "eth0" "1" "0t 1 3 4 5"
142 add_switch_vlan "eth0" "2" "0t 2"
143 ;;
144
145 tl-wr1043nd)
146 set_interfaces_lan_wan "eth0.1" "eth0.2"
147 add_switch "rtl8366rb" "1" "1"
148 add_switch_vlan "rtl8366rb" "1" "1 2 3 4 5t"
149 add_switch_vlan "rtl8366rb" "2" "0 5t"
150 ;;
151
152 tl-wr841n-v1|\
153 tl-wr941nd)
154 set_interface_raw "eth" "eth0"
155 set_interfaces_lan_wan "lan1 lan2 lan3 lan4" "wan"
156 ;;
157
158 wrt160nl)
159 set_interfaces_lan_wan "eth0" "eth1"
160 add_switch "eth0" "1" "1"
161 add_switch_vlan "eth0" "1" "0 1 2 3 4 5"
162 ;;
163
164 wzr-hp-g300nh)
165 set_interfaces_lan_wan "eth0.1" "eth1"
166 add_switch "switch0" "1" "1"
167 add_switch_vlan "switch0" "1" "0 1 2 3 5t"
168 ;;
169
170 aw-nr580 |\
171 bullet-m |\
172 eap7660d |\
173 rb-411 |\
174 tl-wa901nd-v2 |\
175 tl-wr703n |\
176 wp543)
177 set_interface_lan "eth0"
178 ;;
179
180 ap83 |\
181 jwap003 |\
182 pb42 |\
183 pb44 |\
184 routerstation)
185 set_interfaces_lan_wan "eth1" "eth0"
186 ;;
187
188 ap121 |\
189 ap121-mini |\
190 ap96 |\
191 dir-600-a1 |\
192 dir-615-c1 |\
193 ja76pf |\
194 rb750 |\
195 tew-632brp |\
196 tl-mr3220 |\
197 tl-mr3420 |\
198 tl-wr741nd |\
199 tl-wr741nd-v4 |\
200 whr-g301n |\
201 whr-hp-g300n |\
202 whr-hp-gn |\
203 wzr-hp-ag300h)
204 set_interfaces_lan_wan "eth0" "eth1"
205 add_switch "eth0" "1" "1"
206 add_switch_vlan "eth0" "1" "0 1 2 3 4"
207 ;;
208
209 *)
210 set_interfaces_lan_wan "eth0" "eth1"
211 ;;
212 esac
213
214 uci commit network
215
216 exit 0
This page took 0.044997 seconds and 3 git commands to generate.