Remove docs menu.inc and uci_menu.inc
[web.git] / docs / uci_net.txt
1 ---
2 ---
3 Network configuration
4 =====================
5
6 == Network configuration
7
8 The central network configuration is located in the file **'/etc/config/network'**. This configuration file is responsible for defining _switch VLANs_, _interface configurations_ and _network routes_.
9
10 After editing and saving '/etc/config/network' you need to execute '/etc/init.d/network reload' to stop and restart the network before any changes take effect. Rebooting the router is not necessary.
11
12 Feel free to inform yourself about link:procd.html[netifd] (Network Interface Daemon).
13
14 == Sections
15
16 Below is an overview of the section types that may be defined in the network configuration. A minimal network configuration for a router usually consists of at least two _interfaces_ ('lan' and 'wan') and a _switch_ section if applicable.
17
18 === Global Settings
19
20 The 'globals' section contains interface-independent options affecting the network configuration in general.
21
22 [cols="4*1,4",options="header"]
23 |====
24 | Name | Type | Required | Default | Description
25 | 'ula_prefix' | IPv6-prefix | no | _(none)_ | IPv6 ULA-Prefix for this device
26 |====
27
28 === Switch
29
30 The 'switch' section is responsible for partitioning the switch into several _VLANs_ which appear as independent interfaces in the system although they share the same hardware. **Not every OpenWrt supported device (or architecture, like x86) has a programmable switch**, therefore this section might not be present on some platforms. Please also note, that some switches only support 4Bit-VLANs.
31
32 There are currently two different configuration formats in use, one for the legacy '/proc/switch/' API and one for the newer swconfig-based switch configuration.
33
34 === /proc/switch ===
35
36 This variant is actually only found on Broadcom devices like the WRT54GL.
37
38 A typical configuration for it looks like this:
39
40 ----
41 config 'switch' 'eth0'
42 option 'vlan0' '0 1 2 3 5*'
43 option 'vlan1' '4 5'
44 ----
45
46 The 'eth0' identifier specifies the switch the section is belonging to.
47 VLANs are defined by 'vlan#' options with '#' being the VLAN number.
48
49 === swconfig ===
50
51 The newer swconfig framework is intended to replace the legacy switch configuration.
52
53 Configuration for swconfig have a slightly different structure with one extra section per VLAN.
54 The example below shows a typical configuration:
55
56 ----
57 config 'switch' 'eth0'
58 option 'reset' '1'
59 option 'enable_vlan' '1'
60
61 config 'switch_vlan' 'eth0_1'
62 option 'device' 'eth0'
63 option 'vlan' '1'
64 option 'ports' '0 1 2 3 5t'
65
66 config 'switch_vlan' 'eth0_2'
67 option 'device' 'eth0'
68 option 'vlan' '2'
69 option 'ports' '4 5t'
70 ----
71
72 Common properties are defined within the 'switch' section; vlan specific properties are located in additional 'switch_vlan' sections linked to the 'switch' section through the 'device' option.
73
74 === Interfaces
75
76 Sections of the type 'interface' declare logical networks serving as containers for IP address settings, aliases, routes, physical interface names and firewall rules - they play a central role within the OpenWrt configuration concept.
77
78 A minimal interface declaration consists of the following lines:
79
80 ----
81 config 'interface' 'wan'
82 option 'proto' 'dhcp'
83 option 'ifname' 'eth0.1'
84 ----
85
86 * 'wan' is a unique _logical interface name_
87 * 'dhcp' specifies the _interface protocol_, DHCP in this example
88 * 'eth0.1' is the _physical interface_ associated with this section
89
90 *CAUTION*: The system limits the interface name length to 15 characters including the automatically added prefix that is added for some protocols (e.g. "6in4-", "pppoa-", "pppoe-") or due to bridge status ("br-"). Depending on the protocol type, the _logical interface name_ may thus be limited to only 9 characters. E.g. 'abcde67890' is a valid interface name for a normal interface using dhcp, but not for a pppoe interface where the final name would be 'pppoe-abcde67890', which is >15 chars. Using a too long name may lead into errors, as some of the settings in network, firewall or dhcp config may be left unapplied.
91
92 The _interface protocol_ may be one of the following:
93
94 [cols="1,4,2",options="header"]
95 |====
96 | Protocol | Description | Program
97 | 'static' | Static configuration with fixed address and netmask | 'ip'/'ifconfig'
98 | 'dhcp' | Address and netmask are assigned by DHCP | 'udhcpc' (Busybox)
99 | 'dhcpv6' | Address and netmask are assigned by DHCPv6 | 'odhcpc6c'
100 | 'ppp' | PPP protocol - dialup modem connections | 'pppd'
101 | 'pppoe' | PPP over Ethernet - DSL broadband connection | 'pppd' + 'plugin rp-pppoe.so'
102 | 'pppoa' | PPP over ATM - DSL connection using a builtin modem | 'pppd' + plugin ...
103 | '3g' | CDMA, UMTS or GPRS connection using an AT-style 3G modem | 'comgt'
104 | 'qmi' | USB modems using QMI protocol | 'uqmi'
105 | 'ncm' | USB modems using NCM protocol | 'comgt-ncm' + ?
106 | 'wwan' | USB modems with protocol autodetection | 'wwan'
107 | 'hnet' | Self-managing home network (HNCP) | 'hnet-full'
108 | 'pptp' | Connection via PPtP VPN | ?
109 | '6in4' | IPv6-in-IPv4 tunnel for use with Tunnel Brokers like HE.net | ?
110 | 'aiccu' | Anything-in-anything tunnel | 'aiccu'
111 | '6to4' | Stateless IPv6 over IPv4 transport | ?
112 | '6rd' | IPv6 rapid deployment | '6rd'
113 | 'dslite' | Dual-Stack Lite | 'ds-lite'
114 | 'l2tp' | PPP over L2TP Pseudowire Tunnel | 'xl2tpd'
115 | 'relay' | relayd pseudo-bridge | 'relayd'
116 | 'gre', 'gretap' | GRE over IPv4 | 'gre' + 'kmod-gre'
117 | 'grev6', 'grev6tap' | GRE over IPv6 | 'gre' + 'kmod-gre6'
118 | 'vti' | VTI over IPv4 | 'vti' + 'kmod-ip_vti'
119 | 'vtiv6' | VTI over IPv6 | 'vti' + 'kmod-ip6_vti'
120 | 'none' | Unspecified protocol, therefore all the other interface settings will be ignored (like disabling the configuration) | -
121 |====
122
123 Depending on the used _interface protocol_ several other options may be required for a complete interface declaration. The corresponding options for each protocol are listed below. Options marked as "yes" in the "Required" column _must_ be defined in the interface section if the corresponding protocol is used, options marked as "no" _may_ be defined but can be omitted as well.
124
125 === Options valid for all protocol types ===
126
127 [cols="4*1,4",options="header"]
128 |====
129 | Name | Type | Required | Default | Description
130 | 'ifname' | interface name(s) | yes(*) | _(none)_ | Physical interface name to assign to this section, list of interfaces if type bridge is set. _(*) This option may be empty or missing if only a wireless interface references this network or if the protocol type is 'pptp', 'pppoa' or '6in4'_
131 | 'type' | string | no | _(none)_ | If set to "bridge", a bridge containing the given _ifnames_ is created
132 | 'stp' | boolean | no | '0' | Only valid for type "bridge", enables the Spanning Tree Protocol
133 | 'bridge_empty' | boolean | no | '0' | Only valid for type "bridge", enables creating empty bridges
134 | 'igmp_snooping' | boolean | no | '1' | Only valid for type "bridge", sets the multicast_snooping kernel setting for a bridge
135 | 'macaddr' | mac address | no | _(none)_ | Override MAC address of this interface
136 | 'mtu' | number | no | _(none)_ | Override the default MTU on this interface
137 | 'auto' | boolean | no | '0' for proto 'none', else '1' | Specifies whether to bring up interface on boot
138 | 'ipv6' | boolean | no | '1' | Specifies whether to enable (1) or disable (0) IPv6 on this interface
139 | 'force_link' | boolean | no | '1' for protocol 'static', else '0' | Specifies whether ip address, route, and optionally gateway are assigned to the interface regardless of the link being active ('1') or only after the link has become active ('0'); when set to '1', carrier sense events do not invoke hotplug handlers
140 | 'enabled' | boolean | no | '1' | enable or disable the interface section
141 | 'ip4table' | string | no | _(none)_ | (ipv4) routing table for routes of this interface. E.g., when proto = dhcp, the dhcp client will add routes to that table
142 | 'ip6table' | string | no | _(none)_ | (ipv6) routing table for routes of this interface. E.g., when proto = dhcp6, the dhcp6 client will add routes to that table
143 |====
144
145 === Protocol "static" ===
146
147 [cols="4*1,4",options="header"]
148 |====
149 | Name | Type | Required | Default | Description
150 | 'ipaddr' | ip address | yes, if no 'ip6addr' is set. | _(none)_ | IP address.
151 | 'netmask' | netmask | yes, if no 'ip6addr' is set | _(none)_ | Netmask
152 | 'gateway' | ip address | no | _(none)_ | Default gateway
153 | 'broadcast' | ip address | no | _(none)_ | Broadcast address (autogenerated if not set)
154 | 'ip6addr' | ipv6 address | yes, if no 'ipaddr' is set | _(none)_ | Assign given IPv6 address to this interface (CIDR notation)
155 | 'ip6ifaceid' | ipv6 suffix | no | ::1 | Allowed values: 'eui64', 'random', fixed value like '::1:2'. When IPv6 prefix (like 'a:b:c:d::') is received from a delegating server, use the suffix (like '::1') to form the IPv6 address ('a:b:c:d::1') for this interface. Useful with several routers in LAN.
156 | 'ip6gw' | ipv6 address | no | _(none)_ | Assign given IPv6 default gateway to this interface
157 | 'ip6assign' | prefix length | no | _(none)_ | Delegate a prefix of given length to this interface
158 | 'ip6hint' | prefix hint (hex) | no | _(none)_ | Hint the subprefix-ID that should be delegated as hexadecimal number
159 | 'ip6prefix' | ipv6 prefix | no | _(none)_ | IPv6 prefix routed here for use on other interfaces
160 | 'ip6class' | list of strings | no | _(none)_ | Define the IPv6 prefix-classes this interface will accept
161 | 'dns' | list of ip addresses | no | _(none)_ | DNS server(s)
162 | 'dns_search' | list of domain names | no | _(none)_ | Search list for host-name lookup
163 | 'metric' | integer | no | '0' | Specifies the default route metric to use
164 |====
165
166 === Protocol "dhcp" ===
167
168 [cols="4*1,4",options="header"]
169 |====
170 | Name | Type | Required | Default | Description
171 | 'broadcast' | boolean | no | '0' | Enable the broadcast flag in DHCP requests, required for certain ISPs, e.g. Charter with DOCSIS 3
172 | 'ipaddr' | IP address | no | _(none)_ | IP address to request from the DHCP server
173 | 'hostname' | string | no | _(none)_ | Hostname to include in DHCP requests
174 | 'clientid' | string | no | _system default_ | Override client identifier in DHCP requests
175 | 'vendorid' | string | no | _system default_ | Override the vendor class in DHCP requests
176 | 'dns' | list of ip addresses | no | _(none)_ | Supplement DHCP-assigned DNS server(s), or use only these if peerdns is 0
177 | 'peerdns' | boolean | no | '1' | Use DHCP-provided DNS server(s)
178 | 'defaultroute' | boolean | no | '1' | Whether to create a default route via the received gateway
179 | 'customroutes' | string | no | _(none)_ | Space-separated list of additional routes to insert via the received gateway
180 | 'metric' | integer | no | '0' | Specifies the route metric to use for both default route and custom routes
181 | 'reqopts' | string | no | _(none)_ | Space-separated list of additional DHCP options to request from the server
182 | 'sendopts' | string | no | _(none)_ | Space-separated list of additional DHCP options to send to the server. Syntax: 'option:value' where 'option' is either an integer code or a symbolic name such as 'hostname'.
183 | 'zone' | firewall zone | no | _(none)_ | Firewall zone to which this interface should be added
184 | 'iface6rd' | logical interface | no | _(none)_ | Logical interface template for auto-configuration of 6rd
185 | 'mtu6rd' | integer | no | _system default_ | MTU of the 6rd interface
186 | 'zone6rd' | firewall zone | no | _system default_ | Firewall zone to which the 6rd interface should be added
187 |====
188
189 **Note:** To automatically configure 6rd from dhcp you need to create an interface with 'option auto 0' and put its name as the 'iface6rd' parameter. In addition you also need to add its name to a suitable firewall zone in /etc/config/firewall.
190
191 === Protocol "dhcpv6" ===
192
193 [cols="4*1,4",options="header"]
194 |====
195 | Name | Type | Required | Default | Description
196 | 'reqaddress' | [try,force,none] | no | try | Behaviour for requesting addresses
197 | 'reqprefix' | [auto,no,0-64] | no | auto | Behaviour for requesting prefixes (numbers denote hinted prefix length). Use 'no' if you only want a single IPv6 address for the AP itself without a subnet for routing
198 | 'clientid' | hexstring | no | _system default_ | Override client identifier in DHCP requests
199 | 'ifaceid' | ipv6 addr | no | _link-local identifier_ | Override the interface identifier for adresses received via RA
200 | 'dns' | list of ip addresses | no | _(none)_ | Supplement DHCP-assigned DNS server(s), or use only these if peerdns is 0
201 | 'peerdns' | boolean | no | '1' | Use DHCP-provided DNS server(s)
202 | 'defaultroute' | boolean | no | '1' | Whether to create an IPv6 default route via the received gateway
203 | 'reqopts' | list of numbers | no | _(none)_ | Specifies a list of additional DHCP options to request
204 | 'noslaaconly' | boolean | no | '0' | Don't allow configuration via SLAAC (RAs) only (implied by reqprefix != no)
205 | 'norelease' | boolean | no | '0' | Don't send a RELEASE when the interface is brought down
206 | 'ip6prefix' | ipv6 prefix | no | _(none)_ | Use an (additional) user-provided IPv6 prefix for distribution to clients
207 | 'iface_dslite' | logical interface | no | _(none)_ | Logical interface template for auto-configuration of DS-Lite
208 |====
209
210 **Note:** To automatically configure ds-lite from dhcpv6 you need to create an interface with 'option auto 0' and put its name as the 'iface_dslite' parameter. In addition you also need to add its name to a suitable firewall zone in /etc/config/firewall.
211
212 === Protocol "ppp" (PPP over Modem) ===
213
214 *CAUTION*: The package 'ppp' must be installed to use PPP.
215
216 [cols="4*1,4",options="header"]
217 |====
218 | Name | Type | Required | Default | Description
219 | 'device' | file path | yes | _(none)_ | Modem device node
220 | 'username' | string | no(?) | _(none)_ | Username for PAP/CHAP authentication
221 | 'password' | string | no(?) | _(none)_ | Password for PAP/CHAP authentication
222 | 'connect' | file path | no | _(none)_ | Path to custom PPP connect script
223 | 'disconnect' | file path | no | _(none)_ | Path to custom PPP disconnect script
224 | 'keepalive' | number | no | _(none)_ | Number of unanswered echo requests before considering the peer dead. The interval between echo requests is 5 seconds.
225 | 'demand' | number | no | _(none)_ | Number of seconds to wait before closing the connection due to inactivity
226 | 'defaultroute' | boolean | no | '1' | Replace existing default route on PPP connect
227 | 'peerdns' | boolean | no | '1' | Use peer-assigned DNS server(s)
228 | 'dns' | list of ip addresses | no | _(none)_ | Override peer-assigned DNS server(s)
229 | 'ipv6' | boolean | no | '0' | Enable IPv6 on the PPP link
230 | 'pppd_options' | string | no | _(none)_ | Additional command line arguments to pass to the pppd daemon
231 |====
232
233 === Protocol "pppoe" (PPP over Ethernet) ===
234
235 *CAUTION*: The packages 'ppp', 'kmod-pppoe' and 'ppp-mod-pppoe' must be installed to use PPPoE.
236
237 ----
238 opkg update
239 opkg install ppp kmod-pppoe ppp-mod-pppoe
240 ----
241
242 [cols="4*1,4",options="header"]
243 |====
244 | Name | Type | Required | Default | Description
245 | 'username' | string | no(?) | _(none)_ | Username for PAP/CHAP authentication
246 | 'password' | string | no(?) | _(none)_ | Password for PAP/CHAP authentication
247 | 'ac' | string | no | _(none)_ | Specifies the Access Concentrator to connect to. If unset, 'pppd' uses the first discovered one
248 | 'service' | string | no | _(none)_ | Specifies the Service Name to connect to, If unset, 'pppd' uses the first discovered one
249 | 'connect' | file path | no | _(none)_ | Path to custom PPP connect script
250 | 'disconnect' | file path | no | _(none)_ | Path to custom PPP disconnect script
251 | 'keepalive' | number | no | _(none)_ | Number of connection failures before reconnect
252 | 'demand' | number | no | _(none)_ | Number of seconds to wait before closing the connection due to inactivity
253 | 'defaultroute' | boolean | no | '1' | Replace existing default route on PPP connect
254 | 'peerdns' | boolean | no | '1' | Use peer-assigned DNS server(s)
255 | 'dns' | list of ip addresses | no | _(none)_ | Override peer-assigned DNS server(s)
256 | 'ipv6' | boolean | no | '0' | Enable IPv6 on the PPP link
257 | 'pppd_options' | string | no | _(none)_ | Additional command line arguments to pass to the pppd daemon, e.g. **debug**
258 |====
259
260 === Protocol "pppoa" (PPP over ATM AAL5) ===
261
262 *CAUTION*: The package 'ppp-mod-pppoa' must be installed to use PPPoA.
263
264 [cols="4*1,4",options="header"]
265 |====
266 | Name | Type | Required | Default | Description
267 | 'vci' | number | no | '35' | PPPoA VCI
268 | 'vpi' | number | no | '8' | PPPoA VPI
269 | 'atmdev' | number | no | '0' | Specifies the ATM adapter number starting with 0. Most systems only have one ATM device and do not need this option
270 | 'encaps' | string | no | 'llc' | PPPoA encapsulation mode: 'llc' (LLC) or 'vc' (VC)
271 | 'username' | string | no(?) | _(none)_ | Username for PAP/CHAP authentication
272 | 'password' | string | no(?) | _(none)_ | Password for PAP/CHAP authentication
273 | 'connect' | file path | no | _(none)_ | Path to custom PPP connect script
274 | 'disconnect' | file path | no | _(none)_ | Path to custom PPP disconnect script
275 | 'keepalive' | number | no | _(none)_ | Number of connection failures before reconnect
276 | 'demand' | number | no | _(none)_ | Number of seconds to wait before closing the connection due to inactivity
277 | 'defaultroute' | boolean | no | '1' | Replace existing default route on PPP connect
278 | 'peerdns' | boolean | no | '1' | Use peer-assigned DNS server(s)
279 | 'dns' | list of ip addresses | no | _(none)_ | Override peer-assigned DNS server(s)
280 | 'ipv6' | boolean | no | '0' | Enable IPv6 on the PPP link
281 | 'pppd_options' | string | no | _(none)_ | Additional command line arguments to pass to the pppd daemon
282 |====
283
284
285 === Protocol "3g" (PPP over EV-DO, CDMA, UMTS or GPRS) ===
286
287 *CAUTION*: The package 'comgt' must be installed to use 3G.
288
289
290 [cols="4*1,4",options="header"]
291 |====
292 | Name | Type | Required | Default | Description
293 | 'device' | file path | yes | _(none)_ | Modem device node
294 | 'service' | string | yes | 'umts' | 3G service type: 'cdma'/'evdo', 'umts'/'umts_only'/'gprs_only' (...._only options limited to Novatel & Option cards and dongles)
295 | 'apn' | string | yes | _(none)_ | Used APN
296 | 'pincode' | number | no | _(none)_ | PIN code to unlock SIM card
297 | 'dialnumber' | string | no | %%*99***1#%% | Modem dial string e.g. *99#
298 | 'maxwait' | number | no | '20' | Number of seconds to wait for modem to become ready
299 | 'username' | string | no(?) | _(none)_ | Username for PAP/CHAP authentication
300 | 'password' | string | no(?) | _(none)_ | Password for PAP/CHAP authentication
301 | 'keepalive' | number | no | _(none)_ | Number of connection failures before reconnect
302 | 'demand' | number | no | _(none)_ | Number of seconds to wait before closing the connection due to inactivity
303 | 'defaultroute' | boolean | no | '1' | Replace existing default route on PPP connect
304 | 'peerdns' | boolean | no | '1' | Use peer-assigned DNS server(s)
305 | 'dns' | list of ip addresses | no | _(none)_ | Override peer-assigned DNS server(s)
306 | 'ipv6' | boolean | no | '0' | Enable IPv6 on the PPP link
307 |====
308
309
310 === Protocol "qmi" (USB modems using QMI protocol) ===
311
312 *CAUTION*: The package 'uqmi' must be installed to use QMI.
313
314 [cols="4*1,4",options="header"]
315 |====
316 | Name | Type | Required | Default | Description
317 | 'device' | file path | yes | _(none)_ | QMI device node, typically /dev/cdc-wdm0
318 | 'apn' | string | yes | _(none)_ | Used APN
319 | 'pincode' | number | no | _(none)_ | PIN code to unlock SIM card
320 | 'username' | string | no | _(none)_ | Username for PAP/CHAP authentication
321 | 'password' | string | no | _(none)_ | Password for PAP/CHAP authentication
322 | 'auth' | string | no | _(none)_ | Authentication type: pap, chap, both, none
323 | 'modes' | string | no | _(modem default)_ | Allowed network modes, comma separated list of: all, lte, umts, gsm, cdma, td-scdma
324 | 'delay' | number | no | 0 | Seconds to wait before trying to interact with the modem (some ZTE modems require up to 30 s.)
325 |====
326
327 === Protocol "ncm" (USB modems using NCM protocol) ===
328
329 *CAUTION*: The package 'comgt-ncm' + modem specific driver must be installed to use NCM.
330
331 [cols="4*1,4",options="header"]
332 |====
333 | Name | Type | Required | Default | Description
334 | 'device' | file path | yes | _(none)_ | NCM device node, typically /dev/cdc-wdm0 or /dev/ttyUSB#
335 | 'apn' | string | yes | _(none)_ | Used APN
336 | 'pincode' | number | no | _(none)_ | PIN code to unlock SIM card
337 | 'username' | string | no | _(none)_ | Username for PAP/CHAP authentication
338 | 'password' | string | no | _(none)_ | Password for PAP/CHAP authentication
339 | 'auth' | string | no | _(none)_ | Authentication type: pap, chap, both, none
340 | 'mode' | string | no | _(modem default)_ | Used network mode, not every device support every mode: preferlte, preferumts, lte, umts, gsm, auto
341 | 'pdptype' | string | no | 'IPV4V6' | Used IP-stack mode, 'IP' (for IPv4), 'IPV6' (for IPv6) or 'IPV4V6' (for dual-stack) (Designated Driver #46844 and later)
342 | 'delay' | number | no | 0 | Seconds to wait before trying to interact with the modem (some modems require up to 30 s.)
343 |====
344
345 === Protocol "wwan" (USB modems autodetecting the above 3G/4G protocols) ===
346
347 *CAUTION*: The package 'wwan' must be installed to use this feature. The "wwan" protocol detects the right protocol (3G/QMI/NCM/MBIM) for the USB Modem model and passes the configuration to the protocol.
348
349 [cols="4*1,4",options="header"]
350 |====
351 | Name | Type | Required | Default | Description
352 | 'apn' | string | yes | _(none)_ | Used APN
353 | 'auth' | string | no | _(none)_ | Authentication type: pap, chap, both, none
354 | 'username' | string | no | _(none)_ | Username for PAP/CHAP authentication
355 | 'password' | string | no | _(none)_ | Password for PAP/CHAP authentication
356 | 'pincode' | number | no | _(none)_ | PIN code to unlock SIM card
357 | 'modes' | string | no | _(modem default)_ | Allowed network modes, comma separated list of: all, lte, umts, gsm, cdma, td-scdma
358 | 'delay' | number | no | 0 | Seconds to wait before trying to interact with the modem (some ZTE modems require up to 30 s.)
359 |====
360
361 === Protocol "hnet" (Self-managing home network (HNCP)) ===
362
363 *CAUTION*: The package 'hnet-full' must be installed to use hnet.
364 *CAUTION*: See link:http://tools.ietf.org/html/draft-ietf-homenet-hncp[here] for details.
365
366 [cols="4*1,4",options="header"]
367 |====
368 | Name | Type | Required | Default | Description
369 | 'mode' | string | no | auto | Interface mode. One of external, guest, adhoc or hybrid.
370 | 'ip6assign' | integer | no | 64 | IPv6-prefix size to assign to this interface if internal.
371 | 'ip4assign' | integer | no | 24 | IPv4-prefix size to assign to this interface if internal.
372 | 'dnsname' | string | no | <device-name> | DNS-Label to assign to interface.
373 |====
374
375 === Protocol "pptp" (Point-to-Point Tunneling Protocol) ===
376
377 *CAUTION*: The package 'ppp-mod-pptp' must be installed to use PPtP. You need to have another section to configure the "parent" device, and you might need to add "<vpn>" to your "wan" zone in the firewall (<vpn> being the "logical interface name" of this section).
378
379 [cols="4*1,4",options="header"]
380 |====
381 | Name | Type | Required | Default | Description
382 | 'server' | ip address | yes | _(none)_ | Remote PPtP server
383 | 'username' | string | no(?) | _(none)_ | Username for PAP/CHAP authentication
384 | 'password' | string | no(?) | _(none)_ | Password for PAP/CHAP authentication
385 | 'keepalive' | number | no | _(none)_ | Number of unanswered echo requests before considering the peer dead. The interval between echo requests is 5 seconds.
386 | 'demand' | number | no | _(none)_ | Number of seconds to wait before closing the connection due to inactivity
387 | 'defaultroute' | boolean | no | '1' | Replace existing default route on PPtP connect
388 | 'peerdns' | boolean | no | '1' | Use peer-assigned DNS server(s)
389 | 'dns' | list of ip addresses | no | _(none)_ | Override peer-assigned DNS server(s)
390 | 'ipv6' | boolean | no | '0' | Enable IPv6 on the PPtP link
391 | 'pppd_options' | string | no | _(none)_ | Additional command line arguments to pass to the pppd daemon
392 |====
393
394 === Protocol "6in4" (IPv6-in-IPv4 Tunnel) ===
395
396 *CAUTION*: The package '6in4' must be installed to use this protocol.
397
398 [cols="4*1,4",options="header"]
399 |====
400 | Name | Type | Required | Default | Description
401 | 'ipaddr' | IPv4 address | no | Current WAN IPv4 address | Local IPv4 endpoint address
402 | 'peeraddr' | IPv4 address | yes | _(none)_ | Remote IPv4 endpoint address
403 | 'ip6addr' | IPv6 address (CIDR) | yes | _(none)_ | Local IPv6 address delegated to the tunnel endpoint
404 | 'ip6prefix' | IPv6 prefix | no | _(none)_ | Routed IPv6 prefix for downstream interfaces
405 | 'sourcerouting' | boolean | no | '1' | Whether to route only packets from delegated prefixes
406 | 'defaultroute' | boolean | no | '1' | Whether to create an IPv6 default route over the tunnel
407 | 'ttl' | integer | no | '64' | TTL used for the tunnel interface
408 | 'tos' | string | no | _(none)_ | Type Of Service : either "inherit" (the outer header inherits the value of the inner header) or an hexadecimal value. Also known as DSCP.
409 | 'mtu' | integer | no | '1280' | MTU used for the tunnel interface
410 | 'tunnelid' | integer | no | _(none)_ | HE.net global tunnel ID (used for endpoint update)
411 | 'username' | string | no | _(none)_ | HE.net username which you use to login into tunnelbroker, not the User ID shows after you have login int (used for endpoint update)
412 | 'password' | string | no | _(none)_ | HE.net password (used for endpoint update)
413 | 'updatekey' | string | no | _(none)_ | HE.net updatekey, overrides password (used for endpoint update)
414 | 'metric' | integer | no | '0' | Specifies the default route metric to use
415 |====
416
417 **Note:** This protocol type does not need an 'ifname' option set in the interface section. The interface name is derived from the section name, e.g. 'config interface sixbone' would result in an interface named '6in4-sixbone'.
418
419 **Note:** although ip6prefix isn't required, sourcerouting, enabled by default, will prevent forwarding of packets unless ip6prefix is specified.
420
421 === Protocol "aiccu" (Automatic IPv6 Connectivity Client Utility) ===
422
423 *CAUTION*: The package 'aiccu' must be installed to use this protocol. This utility is not meant to be operated in a headless mode. Do not use it if you have some other option. Only AYIYA tunnel type has been tested. For static or heartbeat tunnels, use native 6in4 tunnel instead, perhaps with the he.net Tunnel Broker.
424
425 [cols="4*1,4",options="header"]
426 |====
427 | Name | Type | Required | Default | Description
428 | 'username' | string | yes | _(none)_ | Server username
429 | 'password' | string | yes | _(none)_ | Server password
430 | 'protocol' | string | no | _(none)_ | Tunnel setup protocol to use ('tic', 'tsp', 'l2tp')
431 | 'server' | string | no | 'tic.sixxs.net' | Tunnel setup server to use
432 | 'ip6addr' | IPv6 address (CIDR) | no | _(none)_ | Local IPv6 address delegated to the tunnel endpoint (not necessary)
433 | 'ntpsynctimeout' | integer | no | '90' | Wait for NTP sync that many seconds
434 | 'tunnelid' | integer | no | _(none)_ | TIC server tunnel ID
435 | 'ip6prefix' | IPv6 prefix | no | _(none)_ | Routed IPv6 prefix for downstream interfaces
436 | 'defaultroute' | boolean | no | '1' | Whether to create an IPv6 default route over the tunnel
437 | 'sourcerouting' | boolean | no | '1' | Whether to route only packets from delegated prefixes
438 | 'tunnelid' | integer | no | _(none)_ | TIC server tunnel ID
439 | 'requiretls' | boolean | no | '0' | Require TLS connection to TIC server
440 | 'nat' | boolean | no | '1' | Notify the user that a NAT-kind network is detected
441 | 'heartbeat' | boolean | no | '1' | Make heartbeats
442 | 'verbose' | boolean | no | '0' | Verbose logging to system log
443 |====
444
445 **Note:** This protocol type does not need an 'ifname' option set in the interface section. The interface name is derived from the section name, e.g. 'config interface sixbone' would result in an interface named 'aiccu-sixbone'.
446
447 === Protocol "6to4" (IPv6-in-IPv4 Tunnel) ===
448
449 *CAUTION*: The package '6to4' must be installed to use this protocol.
450
451 [cols="4*1,4",options="header"]
452 |====
453 | Name | Type | Required | Default | Description
454 | 'ipaddr' | IPv4 address | no | Current WAN IPv4 address | Local IPv4 endpoint address
455 | 'defaultroute' | boolean | no | '1' | Whether to create an IPv6 default route over the tunnel
456 | 'ttl' | integer | no | '64' | TTL used for the tunnel interface
457 | 'tos' | string | no | _(none)_ | Type Of Service : either "inherit" (the outer header inherits the value of the inner header) or an hexadecimal value
458 | 'mtu' | integer | no | '1280' | MTU used for the tunnel interface
459 | 'metric' | integer | no | '0' | Specifies the default route metric to use
460 | 'adv_interface' | string | no | 'lan' | (deprecated) The _logical interface name_ of the network the subnet should be advertised on. Multiple interface names can be given.
461 | 'adv_subnet' | hex number | no | '1' | (deprecated) A subnet ID between '1' and 'FFFF' which selects the advertised /64 prefix from the mapped 6to4 space. The subnet ID is incremented by 1 for every interface specified in 'adv_interface'.
462 | 'adv_valid_lifetime' | integer | no | '300' | (deprecated) Overrides the advertised valid prefix lifetime, in seconds
463 | 'adv_preferred_lifetime' | integer | no | '120' | (deprecated) Overrides the advertised preferred prefix lifetime, in seconds
464 |====
465
466 **Note:** This protocol type does not need an 'ifname' option set in the interface section. The interface name is derived from the section name, e.g. 'config interface wan6' would result in an interface named '6to4-wan6'
467
468 **Note:** If radvd is installed and enabled, the 6to4 scripts will add a temporary prefix and interface declaration to the _radvd_ uci configuration and perform a daemon restart if required. (deprecated)
469
470 === Protocol "6rd" (IPv6 rapid deployment) ===
471
472 *CAUTION*: The package '6rd' must be installed to use this protocol.
473
474 *CAUTION*: The needed tunnel values are usually obtained via the DHCPv4 request for the WAN interface. Try that first. Below is only needed for hardcoding the tunnel.
475
476 [cols="4*1,4",options="header"]
477 |====
478 | Name | Type | Required | Default | Description
479 | 'peeraddr' | IPv4 address | yes | no | 6rd - Gateway
480 | 'ipaddr' | IPv4 address | no | Current WAN IPv4 address | Local IPv4 endpoint address
481 | 'ip6prefix' | IPv6 prefix (without length) | yes | no | 6rd-IPv6 Prefix
482 | 'ip6prefixlen' | IPv6 prefix length | yes | no | 6rd-IPv6 Prefix length
483 | 'ip4prefixlen' | IPv6 prefix length | no | 0 | IPv4 common prefix
484 | 'defaultroute' | boolean | no | '1' | Whether to create an IPv6 default route over the tunnel
485 | 'ttl' | integer | no | '64' | TTL used for the tunnel interface
486 | 'tos' | string | no | _(none)_ | Type Of Service : either "inherit" (the outer header inherits the value of the inner header) or an hexadecimal value
487 | 'mtu' | integer | no | '1280' | MTU used for the tunnel interface
488 |====
489
490 **Note:** This protocol type does not need an 'ifname' option set in the interface section. The interface name is derived from the section name, e.g. 'config interface wan6' would result in an interface named '6rd-wan6'.
491
492 **Note:** Some ISP's give you the number of bytes you should use from your WAN IP to calculate your IPv6 address. ip4prefixlen expects the _prefix_ bytes of your WAN IP to calculate the IPv6 address. So if your ISP gives you 14 bytes to calculate, enter 18 (32 - 14).
493
494
495 === Protocol "dslite" (Dual-Stack Lite) ===
496
497 *CAUTION*: The package 'ds-lite' must be installed to use this protocol.
498
499 [cols="4*1,4",options="header"]
500 |====
501 | Name | Type | Required | Default | Description
502 | 'peeraddr' | IPv6 address | yes | no | DS-Lite AFTR address
503 | 'ip6addr' | IPv6 address | no | Current WAN IPv6 address | Local IPv6 endpoint address
504 | 'tunlink' | Logical Interface | no | Current WAN interface | Tunnel base interface
505 | 'defaultroute' | boolean | no | '1' | Whether to create an IPv6 default route over the tunnel
506 | 'ttl' | integer | no | '64' | TTL used for the tunnel interface
507 | 'mtu' | integer | no | '1280' | MTU used for the tunnel interface
508 |====
509
510 *CAUTION*: ds-lite operation requires that IPv4 NAT is disabled. You should adjust your settings in /etc/config/firewall accordingly.
511
512 **Note:** This protocol type does not need an 'ifname' option set in the interface section. The interface name is derived from the section name, e.g. 'config interface wan' would result in an interface named 'dslite-wan'.
513
514
515 === Protocol "l2tp" (PPP over L2TP Pseudowire Tunnel) ===
516
517 *CAUTION*: The package 'xl2tpd' must be installed to use this protocol.
518
519 Most options are similar to protocol "ppp".
520
521 [cols="4*1,4",options="header"]
522 |====
523 | Name | Type | Required | Default | Description
524 | 'server' | string | yes | _(none)_ | L2TP server to connect to. Acceptable datatypes are hostname or IP address, with optional port separated by colon ':'. Note that specifying port is only supported recently and should appear in DD release
525 | 'username' | string | no | _(none)_ | Username for PAP/CHAP authentication
526 | 'password' | string | yes if 'username' is provided | _(none)_ | Password for PAP/CHAP authentication
527 | 'ipv6' | bool | no | 0 | Enable IPv6 on the PPP link (IPv6CP)
528 | 'mtu' | int | no | 'pppd' default | Maximum Transmit/Receive Unit, in bytes
529 | 'keepalive' | string | no | _(none)_ | Number of unanswered echo requests before considering the peer dead. The interval between echo requests is 5 seconds.
530 | 'checkup_interval' | int | no | _(none)_ | Number of seconds to pass before checking if the interface is not up since the last setup attempt and retry the connection otherwise. Set it to a value sufficient for a successful L2TP connection for you. It's mainly for the case that netifd sent the connect request yet xl2tpd failed to complete it without the notice of netifd
531 | 'pppd_options' | string | no | _(none)_ | Additional options to pass to 'pppd'
532 |====
533
534 The name of the physical interface will be "l2tp-<logical interface name>".
535
536 === Protocol "relay" (Relayd Pseudo Bridge) ===
537
538 *CAUTION*: The package 'relayd' must be installed to use this protocol.
539
540 [cols="4*1,4",options="header"]
541 |====
542 | Name | Type | Required | Default | Description
543 | 'network' | list of _logical interface names_ | yes | _(none)_ | Specifies the networks between which traffic is relayed
544 | 'gateway' | IPv4 address | no | _(network default)_ | Override the gateway address sent to clients within DHCP responses
545 | 'expiry' | integer | no | '30' | Host expiry timeout in seconds
546 | 'retry' | integer | no | '5' | Number of ARP ping retries before a host is considered dead
547 | 'table' | integer | no | '16800' | Table ID for automatically added routes
548 | 'forward_bcast' | boolean | no | '1' | Enables forwarding of broadcast traffic, '0' disables it
549 | 'forward_dhcp' | boolean | no | '1' | Enables forwarding of DHCP requests and responses, '0' disables it
550 |====
551
552
553 === Common options for GRE protocols ===
554
555 *CAUTION*: The package 'gre' must be installed to use GRE. Additionally, you need 'kmod-gre' and/or 'kmod-gre6'.
556
557 Four protocols are defined: "gre", "gretap", "grev6", and "grev6tap". The name of the GRE interface will be 'gre-<logical interface name>' for "gre" and "gretap", and 'grev6-<logical interface name>' for "grev6" and "grev6tap".
558
559 All four protocols accept the following common options:
560
561 [cols="4*1,4",options="header"]
562 |====
563 | Name | Type | Required | Default | Description
564 | 'mtu' | integer | no | 1280 | MTU
565 | 'ttl' | integer | no | 64 | TTL of the encapsulating packets
566 | 'tunlink' | logical interface name | no | _(none)_ | Bind the tunnel to this interface ('dev' option of "ip tunnel")
567 | 'zone' | zone name | no | "wan" | Firewall zone to which the interface will be added
568 | 'tos' | string | no | _(none)_ | Type of Service (IPv4), Traffic Class (IPv6): either "inherit" (the outer header inherits the value of the inner header) or an hexadecimal value
569 | 'ikey' | integer | no | 0 | key for incoming packets
570 | 'okey' | integer | no | 0 | key for outgoing packets
571 | 'icsum' | boolean | no | false | require incoming checksum
572 | 'ocsum' | boolean | no | false | compute outgoing checksum
573 | 'iseqno' | boolean | no | false | require incoming packets serialisation
574 | 'oseqno' | boolean | no | false | perform outgoing packets serialisation
575 |====
576
577 === Protocol "gre" (GRE tunnel over IPv4) ===
578
579 The following options are supported, in addition to all common options above:
580
581 [cols="4*1,4",options="header"]
582 |====
583 | Name | Type | Required | Default | Description
584 | 'ipaddr' | IPv4 address | no | WAN IP | Local endpoint
585 | 'peeraddr' | IPv4 address | yes | _(none)_ | Remote endpoint
586 | 'df' | boolean | no | true | Set "Don't Fragment" flag on encapsulating packets
587 |====
588
589 === Protocol "gretap" (Ethernet GRE tunnel over IPv4) ===
590
591 The following options are supported, in addition to all common options above:
592
593 [cols="4*1,4",options="header"]
594 |====
595 | Name | Type | Required | Default | Description
596 | 'ipaddr' | IPv4 address | no | WAN IP | Local endpoint
597 | 'peeraddr' | IPv4 address | yes | _(none)_ | Remote endpoint
598 | 'df' | boolean | no | true | Set "Don't Fragment" flag on encapsulating packets
599 | 'network' | logical interface name | no | _(none)_ | Logical network to which the tunnel will be added (bridged)
600 |====
601
602 === Protocol "grev6" (GRE tunnel over IPv6) ===
603
604 The following options are supported, in addition to all common options above:
605
606 [cols="4*1,4",options="header"]
607 |====
608 | Name | Type | Required | Default | Description
609 | 'ip6addr' | IPv6 address | no | WAN IP | Local endpoint
610 | 'peer6addr' | IPv6 address | yes | _(none)_ | Remote endpoint
611 | 'weakif' | logical interface name | no | 'lan' | Logical network from which to select the local endpoint if ip6addr parameter is empty and no WAN IP is available
612 |====
613
614 === Protocol "grev6tap" (Ethernet GRE tunnel over IPv6) ===
615
616 The following options are supported, in addition to all common options above:
617
618 [cols="4*1,4",options="header"]
619 |====
620 | Name | Type | Required | Default | Description
621 | 'ip6addr' | IPv6 address | no | WAN IP | Local endpoint
622 | 'peer6addr' | IPv6 address | yes | _(none)_ | Remote endpoint
623 | 'weakif' | logical interface name | no | 'lan' | Logical network from which to select the local endpoint if ip6addr is empty and no WAN IP is available
624 | 'network' | logical interface name | no | _(none)_ | Logical network to which the tunnel will be added (bridged)
625 |====
626
627
628
629 === Protocol "vti" (VTI tunnel over IPv4) ===
630
631 VTI Tunnels are IPsec policies with a fwmark set. The traffic is redirected to the matching VTI interface.
632
633 [cols="4*1,4",options="header"]
634 |====
635 | Name | Type | Required | Default | Description
636 | 'ipaddr' | IPv4 address | no | WAN IP | Local endpoint
637 | 'peeraddr' | IPv4 address | yes | _(none)_ | Remote endpoint
638 | 'mtu' | integer | no | 1280 | MTU
639 | 'tunlink' | logical interface name | no | _(none)_ | Bind the tunnel to this interface ('dev' option of "ip tunnel")
640 | 'zone' | zone name | no | "wan" | Firewall zone to which the interface will be added
641 | 'ikey' | integer | no | 0 | key/fwmark for incoming packets
642 | 'okey' | integer | no | 0 | key/fwmark for outgoing packets
643 |====
644
645 === Protocol "vtiv6" (VTI tunnel over IPv6) ===
646
647 The following options are supported, in addition to all common options above:
648
649 [cols="4*1,4",options="header"]
650 |====
651 | Name | Type | Required | Default | Description
652 | 'ip6addr' | IPv6 address | no | WAN IP | Local endpoint
653 | 'peer6addr' | IPv6 address | yes | _(none)_ | Remote endpoint
654 | 'mtu' | integer | no | 1280 | MTU
655 | 'tunlink' | logical interface name | no | _(none)_ | Bind the tunnel to this interface ('dev' option of "ip tunnel")
656 | 'zone' | zone name | no | "wan" | Firewall zone to which the interface will be added
657 | 'ikey' | integer | no | 0 | key/fwmark for incoming packets
658 | 'okey' | integer | no | 0 | key/fwmark for outgoing packets
659 |====
660
661 === Devices
662 A minimal device declaration consists of the following lines:
663
664 ----
665 config device 'eth0.106'
666 option type '8021q'
667 option name 'eth0.106'
668 option ifname 'eth0'
669 option vid '106'
670 ----
671 === VLAN Interfaces ===
672 VLAN Interfaces may be configured also. If not, they are created on the fly by netifd. Defining VLANs gives more options.
673 The following options are supported:
674
675 [cols="4*1,4",options="header"]
676 |====
677 | Name | Type | Required | Default | Description
678 | 'type' | VLAN Type | no | 802.1q | VLAN type, possible values: 8021q or 8021ad
679 | 'name' | Name | yes | _(none)_ | Name of device, i.e. eth0.5 or vlan5
680 | 'ifname' | Parent interface | yes | _(none)_ | Name of parent/base interface, i.e. eth0
681 | 'vid' | VLAN Id | yes | _(none)_ | VLAN Id
682 | 'macaddr' | MAC | no | _(none)_ | MAC of new interface
683 |====
684
685 MAC address option is send upstream but not merged at time of writng.
686 === ATM Bridges (Ethernet over ATM AAL5)
687
688 *CAUTION*: The package 'br2684ctl' must be installed to use Ethernet over AAL5.
689
690 ATM bridges use a special config section called 'atm-bridge'.
691 Each 'atm-bridge' section maps the specified ATM curcuit an 'atm#' pseudo ethernet device which can
692 be used for example in conjunction with 'pppoe' to establish a DSL connection to the ISP.
693
694 A typical bridge section looks like this:
695 ----
696 config atm-bridge
697 option unit '0'
698 option vpi '8'
699 option vci '35'
700 ----
701
702 * Unit '0' will let 'br2684ctl' create a 'nas0' pseudo device
703 * VPI '8' and VCI '35' specifies the circuit to bridge. Those values are ISP dependant.
704
705 The 'atm-bridge' section allows the following options:
706
707 [cols="4*1,4",options="header"]
708 |====
709 | Name | Type | Required | Default | Description
710 | 'unit' | number | yes | '0' | Specifies the br2684 interface number. If ommitted, '0' is assumed which would result in a 'nas0' pseudo interface.
711 | 'vci' | number | no | '35' | PPPoA VCI
712 | 'vpi' | number | no | '8' | PPPoA VPI
713 | 'atmdev' | number | no | '0' | Specifies the ATM adapter number starting with 0. Most systems only have one ATM device and do not need this option
714 | 'encaps' | string | no | 'llc' | PPPoA encapsulation mode: 'llc' (LLC) or 'vc' (VC)
715 | 'payload' | string | no | 'bridged' | PPPoA forwarding mode: 'routed' or 'bridged'
716 |====
717
718 === DSL / VDSL
719
720 *CAUTION*: This currently only works on devices based on lantiq SoCs.
721
722 (V)DSL uses a special config section called 'dsl', which typically looks like this:
723 ----
724 config vdsl 'dsl'
725 option annex 'b'
726 option firmware '/lib/firmware/vdsl.bin'
727 option tone 'bv'
728 option xfer_mode 'atm'
729 ----
730
731 The 'dsl' section allows the following options:
732
733 [cols="4*1,4",options="header"]
734 |====
735 | Name | Type | Required | Default | Description
736 | 'annex' | string | yes | 'b' | Specifies the Annex setting (ISP/line dependent). Supported values on lantiq AMAZON and DANUBE devices: b, bdmt, b2, b2p, a, at1, alite, admt, a2, a2p, l, m, m2, m2p. Supported values on lantiq ARX100 "AR9" and VRX200 "VR9" devices: a, b, j
737 | 'firmware' | string | yes | '/lib/firmware/vdsl.bin' | The path to the modem's firmware image *CAUTION*: **Only supported by devices with lantiq SoC. See the xDSL firmware section below for more information **
738 | 'tone' | string | yes | 'bv' | The tone mode (ISP/line dependent). Supported values: a = A43, av = A43 + V43, b = B43, bv = B43 + V43 *CAUTION*: **Only supported by devices with ARX100 "AR9" and VRX200 "VR9" lantiq SoC. This configuration was removed in "Designated Driver" as the driver now auto-detects the correct value**
739 | 'xfer_mode' | string | yes | 'atm' | The transfer mode. Supported values are: atm = Asynchronous Transfer Mode (often used for ADSL connections), ptm = Packet Transfer Mode (often used for VDSL connections) *CAUTION*: **Only supported by devices with ARX100 "AR9" and VRX200 "VR9" lantiq SoC.**
740 |====
741
742 === Lantiq xDSL firmware ===
743
744 Starting with r47631 and r47650 (lantiq: add dsl-vr9-firmware-xdsl / lantiq: add dsl-vrx200-firmware-xdsl-b: add Annex B version of VRX200 DSL firmware) there are redistributable versions of the xDSL firmware available as OpenWrt packages:
745
746 * dsl-vrx200-firmware-xdsl-a
747 * dsl-vrx200-firmware-xdsl-b
748
749 A list (incomplete) of other firmware versions, including those with vectoring support, can be found here: link:https:_xdarklight.github.io/lantiq-xdsl-firmware-info/[]
750
751 === Aliases
752
753 Basically create an 'interface' section per IP, but alias interfaces may NOT be of type bridge
754
755 * For non-bridged interfaces (physdev , that is physical interfaces) the 'ifname' is the <interface-of-network-for-same-phydev>
756 * For cases where the interface is bridged the 'ifname' is br-'base-interface', where 'base-interface' is the name of the primary IP's config section (e.g. for a the default lan interface config, the first alias would use ifname br-lan).
757
758 A minimal alias definition for a bridged interface might be (for a scenario without vlans):
759 ----
760 config interface lan
761 option 'ifname' 'eth0'
762 option 'type' 'bridge'
763 option 'proto' 'static'
764 option 'ipaddr' '192.168.1.1'
765 option 'netmask' '255.255.255.0'
766 ----
767
768 ----
769 config interface lan2
770 option 'ifname' 'br-lan'
771 option 'proto' 'static'
772 option 'ipaddr' '10.0.0.1'
773 option 'netmask' '255.255.255.0'
774 ----
775
776 or for a non-bridge interface
777 ----
778 config interface lan
779 option 'ifname' 'eth0'
780 option 'proto' 'static'
781 option 'ipaddr' '192.168.1.1'
782 option 'netmask' '255.255.255.0'
783 ----
784
785 ----
786 config interface lan2
787 option 'ifname' 'eth0'
788 option 'proto' 'static'
789 option 'ipaddr' '10.0.0.1'
790 option 'netmask' '255.255.255.0'
791 ----
792
793 To see a list of interfaces you can do 'ubus list network.interface.*' and to view the ip of a particular interface (the UCI name not the physical interface), do 'ifstatus <interface>' (e.g. 'ifstatus lan2').
794
795 === Aliases: notes ===
796
797 On openwrt 12.09, a lan interface that is first defined as dhcp interface
798 and then has aliases with static ip address could cause problems
799 in routing the lan traffic through the wan zone using the basic lan-wan forwarding provided by openwrt.
800 A solution is: having the basic interface with static address and aliases with dhcp protocol.
801
802 Another note is related to 'how to refer to the ifname of an interface'.
803 Normally the ifname is 'br-wan' if the interface 'wan' is bridged,
804 else is 'ifname <nic_device>' . Another way to avoid to list always the same
805 device is using 'ifname @interface'. In this way, even if the wan interface
806 is not a bridge, one can refer to the physical device used by the wan interface
807 indirectly.
808
809 === IPv4 Routes
810
811 Static _IPv4 routes_ can be defined on specific interfaces using 'route' sections. As for _aliases_, multiple sections can be attached to an interface.
812
813 A minimal example looks like this:
814
815 ----
816 config 'route' 'name_your_route'
817 option 'interface' 'lan'
818 option 'target' '172.16.123.0'
819 option 'netmask' '255.255.255.0'
820 option 'gateway' '172.16.123.100'
821 ----
822
823 * 'lan' is the _logical interface name_ of the parent interface
824 * '172.16.123.0' is the _network address_ of the route
825 * '255.255.255.0' specifies the _route netmask_
826
827 Legal options for _IPv4 routes_ are:
828
829 [cols="4*1,4",options="header"]
830 |====
831 | Name | Type | Required | Default | Description
832 | 'interface' | string | yes | _(none)_ | Specifies the _logical interface name_ of the parent (or master) interface this route belongs to; must refer to one of the defined 'interface' sections
833 | 'target' | ip address | yes | _(none)_ | Network address
834 | 'netmask' | netmask | no | _(none)_ | Route netmask. If omitted, '255.255.255.255' is assumed which makes 'target' a _host address_
835 | 'gateway' | ip address | no | _(none)_ | Network gateway. If omitted, the 'gateway' from the parent interface is taken; if set to '0.0.0.0' no gateway will be specified for the route
836 | 'metric' | number | no | '0' | Specifies the _route metric_ to use
837 | 'mtu' | number | no | _interface MTU_ | Defines a specific MTU for this route
838 | 'table' | routing table | no | _(none)_ | Defines the table ID to use for the route. The ID can be either a numeric table index ranging from 0 to 65535 or a symbolic alias declared in /etc/iproute2/rt_tables. The special aliases local (255), main (254) and default (253) are recognized as well
839 | 'source' | ip address | no | _(none)_ | The preferred source address when sending to destinations covered by the target
840 | 'onlink' | boolean | no | '0' | When enabled gateway is on link even if the gateway does not match any interface prefix
841 | 'type' | string | no | 'unicast' | One of the types outlined in the Routing Types table below
842 |====
843
844 To disable a route quickly, the option 'enabled' is not available. Just rewrite the 'route' config section as 'disabled_route' like:
845 ----
846 config 'disabled_route' 'name_your_route'
847 ...lines...
848 ----
849 and it will be recognized by the uci parser but not applied by the '/etc/init.d/network' script.
850
851 *CAUTION*: It seems that on openwrt 12.09 if a route is defined using a gateway in an address space where a gateway is already defined, it will be not added. Like the lan has the gateway 192.168.1.1 and we want to go to 1.2.3.4 over the gateway 192.168.1.5 within the interface lan, it will not be added. Could be added through 'ip route' commands tough.
852 === IPv6 Routes
853
854 _IPv6 routes_ can be specified as well by defining one or more 'route6' sections.
855
856 A minimal example looks like this:
857
858 ----
859 config 'route6'
860 option 'interface' 'lan'
861 option 'target' '2001:0DB8:100:F00:BA3::1/64'
862 option 'gateway' '2001:0DB8:99::1'
863 ----
864
865 * 'lan' is the _logical interface name_ of the parent interface
866 * '2001:0DB8:100:F00:BA3::1/64' is the routed _IPv6 subnet_ in CIDR notation
867 * '2001:0DB8:99::1' specifies the _IPv6 gateway_ for this route
868
869 Legal options for _IPv6 routes_ are:
870
871 [cols="4*1,4",options="header"]
872 |====
873 | Name | Type | Required | Default | Description
874 | 'interface' | string | yes | _(none)_ | Specifies the _logical interface name_ of the parent (or master) interface this route belongs to; must refer to one of the defined 'interface' sections
875 | 'target' | ipv6 address | yes | _(none)_ | IPv6 network address
876 | 'gateway' | ipv6 address | no | _(none)_ | IPv6 gateway. If omitted, the 'gateway' from the parent interface is taken
877 | 'metric' | number | no | '0' | Specifies the _route metric_ to use
878 | 'mtu' | number | no | _interface MTU_ | Defines a specific MTU for this route
879 | 'table' | routing table | no | _(none)_ | Defines the table ID to use for the route. The ID can be either a numeric table index ranging from 0 to 65535 or a symbolic alias declared in /etc/iproute2/rt_tables. The special aliases local (255), main (254) and default (253) are recognized as well
880 | 'source' | ip address | no | _(none)_ | The preferred source address when sending to destinations covered by the target
881 | 'onlink' | boolean | no | '0' | When enabled gateway is on link even if the gateway does not match any interface prefix
882 | 'type' | string | no | 'unicast' | One of the types outlined in the Routing Types table below
883 |====
884
885 === Routing Types ===
886
887 [cols="1,4",options="header"]
888 |====
889 | Type | Description
890 | 'unicast' | the route entry describes real paths to the destinations covered by the route prefix.
891 | 'local' | the destinations are assigned to this host. The packets are looped back and delivered locally.
892 | 'broadcast' | the destinations are broadcast addresses. The packets are sent as link broadcasts.
893 | 'multicast' | a special type used for multicast routing. It is not present in normal routing tables.
894 | 'unreachable' | these destinations are unreachable. Packets are discarded and the ICMP message host unreachable is generated. The local senders get an EHOSTUNREACH error.
895 | 'prohibit' | these destinations are unreachable. Packets are discarded and the ICMP message communication administratively prohibited is generated. The local senders get an EACCES error.
896 | 'blackhole' | these destinations are unreachable. Packets are discarded silently. The local senders get an EINVAL error.
897 | 'anycast' | the destinations are anycast addresses assigned to this host. They are mainly equivalent to local with one difference: such addresses are invalid when used as the source address of any packet.
898 |====
899
900
901 === IP rules
902
903 netifd supports _IP rule_ declarations which are required to implement policy routing. IPv4 rules can be defined by declaring one or more sections of type 'rule', IPv6 rules are denoted by sections of type 'rule6'. Both types share the same set of defined options.
904
905 A simple IPv4 rule may look like:
906
907 ----
908 config rule
909 option mark '0xFF'
910 option in 'lan'
911 option dest '172.16.0.0/16'
912 option lookup '100'
913 ----
914
915 * '0xFF' is a fwmark to be matched
916 * 'lan' is the incoming _logical interface name_
917 * '172.16.0.0/16' is the destination subnet to match
918 * '100' is the routing table ID to use for the matched traffic
919
920 Similary, an IPv6 rule looks like:
921
922 ----
923 config rule6
924 option in 'vpn'
925 option dest 'fdca:1234::/64'
926 option action 'prohibit'
927 ----
928
929 * 'vpn' is the incoming _logical interface name_
930 * 'fdca:1234::/64' is the destination subnet to match
931 * 'prohibit' is a routing action to take
932
933 The options below are defined for _IP rule_ ('rule' and 'rule6') sections:
934
935 [cols="4*1,4",options="header"]
936 |====
937 | Name | Type | Required | Default | Description
938 | 'in' | string | no | _(none)_ | Specifies the incoming _logical interface name_
939 | 'out' | string | no | _(none)_ | Specifies the outgoing _logical interface name_
940 | 'src' | ip subnet | no | _(none)_ | Specifies the source subnet to match (CIDR notation)
941 | 'dest' | ip subnet | no | _(none)_ | Specifies the destination subnet to match (CIDR notation)
942 | 'tos' | integer | no | _(none)_ | Specifies the TOS value to match in IP headers
943 | 'mark' | mark/mask | no | _(none)_ | Specifies the _fwmark_ and optionally its mask to match, e.g. '0xFF' to match mark 255 or '0x0/0x1' to match any even mark value
944 | 'invert' | boolean | no | '0' | If set to '1', the meaning of the match options is inverted
945 | 'priority' | integer | no | _(incrementing)_ | Controls the order of the IP rules, by default the priority is auto-assigned so that they are processed in the same order they're declared in the config file
946 | 'lookup' | routing table | at least one of | _(none)_ | The rule target is a table lookup, the ID can be either a numeric table index ranging from '0' to '65535' or a symbolic alias declared in '/etc/iproute2/rt_tables'. The special aliases 'local' ('255'), 'main' ('254') and 'default' ('253') are recognized as well
947 | 'goto' | rule index | ::: | ::: | The rule target is a jump to another rule specified by its 'priority' value
948 | 'action' | string | ::: | ::: | The rule target is one of the routing actions outlined in the table below
949 |====
950
951 === Routing Actions ===
952
953 [cols="1,4",options="header"]
954 |====
955 | Action | Description
956 | 'prohibit' | When reaching the rule, respond with _ICMP prohibited_ messages and abort route lookup
957 | 'unreachable' | When reaching the rule, respond with _ICMP unreachable_ messages and abort route lookup
958 | 'blackhole' | When reaching the rule, drop packet and abort route lookup
959 | 'throw' | Stop lookup in the current routing table even if a default route exists
960 |====
961
962 == Examples
963
964 Below are a few examples for special, non-standard interface configurations.
965
966 === Bridge without IP
967
968 ----
969 config 'interface' 'example'
970 option 'type' 'bridge'
971 option 'proto' 'none'
972 option 'ifname' 'eth0 eth1'
973 option 'auto' '1'
974 ----
975
976 === DHCP without default gateway
977
978
979 ----
980 config 'interface' 'example'
981 option 'proto' 'dhcp'
982 option 'ifname' 'eth0'
983 option 'defaultroute' '0'
984 ----
985
986 === DHCP and IPv6
987
988 ----
989 config 'interface' 'example'
990 option 'proto' 'dhcp'
991 option 'ifname' 'eth0'
992
993 config 'alias'
994 option 'interface' 'example'
995 option 'proto' 'static'
996 option 'ip6addr' '2001:0DB8:100:F00:BA3::1'
997 ----
998
999 === Static IP configuration with multiple dnses
1000
1001 ----
1002 config 'interface' 'example'
1003 option 'proto' 'static'
1004 option 'ifname' 'eth0'
1005 option 'ipaddr' '192.168.1.200'
1006 option 'netmask' '255.255.255.0'
1007 list 'dns' '192.168.1.1'
1008 list 'dns' '192.168.10.1'
1009 # the priority is: the last dns listed will be the first one
1010 # to be chosen for the name resolution.
1011 ----
1012
1013 *CAUTION*: Openwrt will use the new dns configured only after a reboot or a '/etc/init.d/dnsmasq restart'.
1014
1015 === Static IP configuration and default gateway with non-zero metric
1016
1017 ----
1018 config 'interface' 'example'
1019 option 'proto' 'static'
1020 option 'ifname' 'eth0'
1021 option 'ipaddr' '192.168.1.200'
1022 option 'netmask' '255.255.255.0'
1023 option 'dns' '192.168.1.1'
1024
1025 config 'route'
1026 option 'interface' 'example'
1027 option 'target' '0.0.0.0'
1028 option 'netmask' '0.0.0.0'
1029 option 'gateway' '192.168.1.1'
1030 option 'metric' '100'
1031 ----
1032
1033 === PPtP-over-PPPoE internet connection
1034
1035 ----
1036 config 'interface' 'wan'
1037 option 'proto' 'pppoe'
1038 option 'ifname' 'eth1'
1039 option 'username' 'user'
1040 option 'password' 'pass'
1041 option 'timeout' '10'
1042
1043 config 'interface' 'vpn'
1044 option 'proto' 'pptp'
1045 option 'ifname' 'vpn'
1046 option 'username' 'vpnuser'
1047 option 'password' 'vpnpass'
1048 option 'server' 'vpn.example.org'
1049 ----
1050
1051 *CAUTION*: Additionally the "wan" firewall zone must include both interfaces in '/etc/config/firewall':
1052
1053 ----
1054 config 'zone'
1055 option 'name' 'wan'
1056 option 'network' 'wan vpn' # Important
1057 option 'input' 'REJECT'
1058 option 'forward' 'REJECT'
1059 option 'output' 'ACCEPT'
1060 option 'masq' '1'
1061 ----
1062
1063 === PPPoA ADSL internet connection
1064
1065 ----
1066 config adsl-device 'adsl'
1067 option fwannex 'a'
1068 option annex 'a'
1069
1070 config interface 'wan'
1071 option proto 'pppoa'
1072 option username 'jbloggs@plusdsl.net'
1073 option password 'XXXXXXXXX'
1074 option vpi '0'
1075 option vci '38'
1076 option encaps 'vc'
1077 ----
1078
1079 === listing an interface created by software on the router, like vpn
1080
1081 For example, a vpn interface is normally "tun0". To list it in the uci config files (and therefore in luci):
1082 ----
1083 config interface 'tun0'
1084 option ifname 'tun0'
1085 option proto 'none'
1086 ----
1087
1088 === Static IPv6-in-IPv4 tunnel
1089
1090 The example below illustrates a static tunnel configuration in '/etc/config/network' file for the Hurricane Electric (he.net) broker.
1091 Option 'ipaddr' specifies the local IPv4 address, 'peeraddr' is the broker IPv4 address and 'ip6addr' the local IPv6 address routed via the tunnel.
1092
1093 ----
1094 config 'interface' 'henet'
1095 option 'proto' '6in4'
1096 option 'ipaddr' '178.24.115.19'
1097 option 'peeraddr' '216.66.80.30'
1098 option 'ip6addr' '2001:0DB8:1f0a:1359::2/64'
1099 ----
1100
1101 *CAUTION*: You should also add an address from your routed IPv6 network to the "lan" interface.
1102
1103 *CAUTION*: To apply IPv6 firewall rules to the tunnel interface, add it to the "wan" zone in '/etc/config/firewall':
1104
1105 ----
1106 config 'zone'
1107 option 'name' 'wan'
1108 option 'network' 'wan henet' # Important
1109 option 'input' 'REJECT'
1110 option 'forward' 'REJECT'
1111 option 'output' 'ACCEPT'
1112 option 'masq' '1'
1113 ----
1114
1115 *CAUTION*: If you define a new, dedicated zone just for the tunnel interface,
1116 make sure to set 'option conntrack 1' in order to force enabling connection tracking,
1117 otherwise unidirectional forwarding rules will not work.
1118
1119 *CAUTION*: Don't forget to set up forwarding rules between the LAN and the tunnel if you want to route IPv6 traffic between them.
1120
1121 === Setup behind one-to-one NAT ===
1122
1123 If your public IP, e.g. '178.24.115.19', is not matching the IP address on your WAN interface, your ISP is probably using link:http://shorewall.net/NAT.htm#One-to-one[one-to-one NAT] (aka link:http://en.wikipedia.org/wiki/Network_address_translation#Methods_of_Port_translation[full-cone NAT]) and you won't be able to establish static IPv6-in-IPv4 tunnel. IP address of your WAN interface can be obtained with the following command:
1124
1125 ----
1126 . /lib/functions/network.sh; network_get_ipaddr ip wan; echo $ip
1127 ----
1128
1129 If this is your case you should fill the WAN IP address into 'ipaddr' option instead of your actual public IP that might have been provided to link:http://he.net/[Hurricane Electric] during tunnel creation. (You should always use your public IP while creating Hurricane Electric tunnel, so don't change it just because you are behind one-to-one NAT.) Or you may completely omit the optional 'ipaddr' option and let auto configuration to handle the correct IP. (*WARNING*: Auto configuration is vague. Is 'uci' handling this case?) That would be preferred solution if your WAN IP is dynamic (i.e. obtained via DHCP) or you are not sure. Example of '/etc/config/network' entry:
1130
1131 ----
1132 config 'interface' 'henet'
1133 option 'proto' '6in4'
1134 option 'peeraddr' '216.66.80.30'
1135 option 'ip6addr' '2001:0DB8:1f0a:1359::2/64'
1136 ----
1137
1138 === Dynamic IPv6-in-IPv4 tunnel (HE.net only)
1139
1140 The example below illustrates a dynamic tunnel configuration for the Hurricane Electric (he.net) broker with enabled IP update.
1141 The local IPv4 address is automatically determined and tunnelid, username and password are provided for IP update.
1142
1143 ----
1144 config 'interface' 'henet'
1145 option 'proto' '6in4'
1146 option 'peeraddr' '216.66.80.30'
1147 option 'ip6addr' '2001:0DB8:1f0a:1359::2/64'
1148 option 'tunnelid' '12345'
1149 option 'username' 'myusername'
1150 option 'password' '098f6bcd4621d373cade4e832627b4f6'
1151 ----
1152
1153 === L2TPv3 Pseudowire bridged to LAN
1154
1155 This example establishes a Pseudowire Tunnel and bridges it to the LAN ports. The existing lan interface is reused with protocol 'l2tp' instead of 'static'.
1156
1157 ----
1158 config 'interface' 'lan'
1159 option 'proto' 'l2tp'
1160 option 'type' 'bridge'
1161 option 'ifname' 'eth0'
1162 option 'ipaddr' '192.168.1.1'
1163 option 'netmask' '255.255.255.0'
1164 option 'localaddr' '178.24.154.19'
1165 option 'peeraddr' '89.44.33.61'
1166 option 'encap' 'udp'
1167 option 'sport' '4000'
1168 option 'dport' '5410'
1169 ----
1170
1171 === Relay between LAN and Wireless Station
1172
1173 This example sets up a 'relayd' pseudo bridge between a wireless client network and LAN, so that it works similarly to the Broadcom Bridged Client mode.
1174
1175 Wireless configuration (excerpt):
1176
1177 ----
1178 config wifi-iface
1179 option 'device' 'radio0'
1180 option 'mode' 'sta'
1181 option 'ssid' 'Some Wireless Network'
1182 option 'encryption' 'psk2'
1183 option 'key' '12345678'
1184 option 'network' 'wwan'
1185 ----
1186
1187 Network configuration (excerpt):
1188
1189 *CAUTION*: Note that the LAN subnet must be different from the one used by wireless network's DHCP.
1190
1191 ----
1192 config 'interface' 'lan'
1193 option 'ifname' 'eth0.1'
1194 option 'proto' 'static'
1195 option 'ipaddr' '192.168.1.1'
1196 option 'netmask' '255.255.255.0'
1197
1198 config 'interface' 'wwan'
1199 option 'proto' 'dhcp'
1200
1201 config 'interface' 'stabridge'
1202 option 'proto' 'relay'
1203 option 'network' 'lan wwan'
1204 ----
1205
1206 In contrast to true bridging, traffic forwarded in this manner is affected by firewall rules, therefore both the wireless client network and the lan network should be covered by the same LAN firewall zone with forward policy set to 'accept' to allow traffic flow between both interfaces:
1207
1208 ----
1209 config 'zone'
1210 option 'name' 'lan'
1211 option 'network' 'lan wwan' # Important
1212 option 'input' 'ACCEPT'
1213 option 'forward' 'ACCEPT' # Important
1214 option 'output' 'ACCEPT'
1215 ----
1216
1217 === Static addressing of a GRE tunnel
1218
1219 Create a GRE tunnel with static address 10.42.0.253/30, adding it to an existing firewall zone called 'tunnels':
1220
1221 ----
1222 config interface mytunnel
1223 option proto gre
1224 option zone tunnels
1225 option peeraddr 198.51.100.42
1226
1227 config interface mytunnel_addr
1228 option proto static
1229 option ifname @mytunnel
1230 option ipaddr 10.42.0.253
1231 option netmask 255.255.255.252
1232 # Fixes IPv6 multicast (long-standing bug in kernel).
1233 # Useful if you run Babel or OSPFv3.
1234 option ip6addr 'fe80::42/64'
1235 ----
1236
1237 == Network management
1238
1239 The complete network configuration can be re-applied by running '/etc/init.d/network restart'. Individual interfaces can be brought up with 'ifup _name_' or down with 'ifdown _name_' where _name_ corresponds to the _logical interface name_ of the corresponding 'config interface' section. An 'ifup' implies a prior 'ifdown' so there is no need to invoke both when reloading an interface.
1240
1241 Note that wireless interfaces are managed externally and 'ifup' may break the relation to existing bridges. In such a case it is required to run 'wifi up' after 'ifup' in order to re-establish the bridge connection.
1242
1243 == Determining Linux interface names
1244
1245 In order to derive a Linux interface name like 'eth1' from a logical network name like 'wan' for use in scripts or tools like 'ifconfig' and 'route' the 'uci' utility can be used as illustrated in the example below which opens port 22 on the interface.
1246
1247 ----
1248 WANIF=$(uci -P/var/state get network.wan.ifname)
1249 iptables -I INPUT -i $WANIF -p tcp --dport 22 -j ACCEPT
1250 ----
1251
1252 The uci state vars are deprecated and not used anymore for network related information link:https:_forum.openwrt.org/viewtopic.php?pid=203787#p203787[Quoting jow in the forum].
1253 Use /lib/functions/network.sh:
1254
1255 ----
1256 source /lib/functions/network.sh
1257
1258 if network_get_ipaddr addr "wan"; then
1259 echo "IP is $addr"
1260 fi
1261 ----
1262
1263 == Multiple IP addresses
1264
1265 Assigning multiple ip addresses to the same interface:
1266 ----
1267 config interface foo
1268 option ifname eth1
1269 list ipaddr 10.8.0.1/24
1270 list ipaddr 10.9.0.1/24
1271 list ip6addr fdca:abcd::1/64
1272 list ip6addr fdca:cdef::1/64
1273 ----
1274
1275 Specifying multiple interfaces sharing the same device:
1276
1277 ----
1278 config interface foo
1279 option ifname eth1
1280 option ipaddr 10.8.0.1
1281 option netmask 255.255.255.0
1282 option ip6addr fdca:abcd::1/64
1283
1284 config interface foo2
1285 option ifname eth1
1286 option ipaddr 10.9.0.1
1287 option netmask 255.255.255.0
1288 option ip6addr fdca:cdef::1/64
1289 ----
1290