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