docs: add menu for UCI config files
[web.git] / docs / uci_net.txt
1 Network configuration
2 =====================
3
4 include::uci_menu.inc[]
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 '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' | integer | no | ? | Number of attempts to reconnect
386 | 'defaultroute' | boolean | no | '1' | Whether to create a default route over the tunnel
387 | 'peerdns' | boolean | no | '1' |Use PPTP-provided DNS server(s)
388 | 'delegate' | boolean | no | ? |Use builtin IPv6-management
389 | 'iface' | string | no(?) | 'pptp-<vpn>' | Name of the physical interface. Defaults to 'pptp-<vpn>' no matter what you use
390 |====
391
392 === Protocol "6in4" (IPv6-in-IPv4 Tunnel) ===
393
394 *CAUTION*: The package '6in4' must be installed to use this protocol.
395
396 [cols="4*1,4",options="header"]
397 |====
398 | Name | Type | Required | Default | Description
399 | 'ipaddr' | IPv4 address | no | Current WAN IPv4 address | Local IPv4 endpoint address
400 | 'peeraddr' | IPv4 address | yes | _(none)_ | Remote IPv4 endpoint address
401 | 'ip6addr' | IPv6 address (CIDR) | yes | _(none)_ | Local IPv6 address delegated to the tunnel endpoint
402 | 'ip6prefix' | IPv6 prefix | no | _(none)_ | Routed IPv6 prefix for downstream interfaces
403 | 'sourcerouting' | boolean | no | '1' | Whether to route only packets from delegated prefixes
404 | 'defaultroute' | boolean | no | '1' | Whether to create an IPv6 default route over the tunnel
405 | 'ttl' | integer | no | '64' | TTL used for the tunnel interface
406 | '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.
407 | 'mtu' | integer | no | '1280' | MTU used for the tunnel interface
408 | 'tunnelid' | integer | no | _(none)_ | HE.net global tunnel ID (used for endpoint update)
409 | '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)
410 | 'password' | string | no | _(none)_ | HE.net password (used for endpoint update)
411 | 'updatekey' | string | no | _(none)_ | HE.net updatekey, overrides password (used for endpoint update)
412 | 'metric' | integer | no | '0' | Specifies the default route metric to use
413 |====
414
415 **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'.
416
417 **Note:** although ip6prefix isn't required, sourcerouting, enabled by default, will prevent forwarding of packets unless ip6prefix is specified.
418
419 === Protocol "aiccu" (Automatic IPv6 Connectivity Client Utility) ===
420
421 *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.
422
423 [cols="4*1,4",options="header"]
424 |====
425 | Name | Type | Required | Default | Description
426 | 'username' | string | yes | _(none)_ | Server username
427 | 'password' | string | yes | _(none)_ | Server password
428 | 'protocol' | string | no | _(none)_ | Tunnel setup protocol to use ('tic', 'tsp', 'l2tp')
429 | 'server' | string | no | 'tic.sixxs.net' | Tunnel setup server to use
430 | 'ip6addr' | IPv6 address (CIDR) | no | _(none)_ | Local IPv6 address delegated to the tunnel endpoint (not necessary)
431 | 'ntpsynctimeout' | integer | no | '90' | Wait for NTP sync that many seconds
432 | 'tunnelid' | integer | no | _(none)_ | TIC server tunnel ID
433 | 'ip6prefix' | IPv6 prefix | no | _(none)_ | Routed IPv6 prefix for downstream interfaces
434 | 'defaultroute' | boolean | no | '1' | Whether to create an IPv6 default route over the tunnel
435 | 'sourcerouting' | boolean | no | '1' | Whether to route only packets from delegated prefixes
436 | 'tunnelid' | integer | no | _(none)_ | TIC server tunnel ID
437 | 'requiretls' | boolean | no | '0' | Require TLS connection to TIC server
438 | 'nat' | boolean | no | '1' | Notify the user that a NAT-kind network is detected
439 | 'heartbeat' | boolean | no | '1' | Make heartbeats
440 | 'verbose' | boolean | no | '0' | Verbose logging to system log
441 |====
442
443 **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'.
444
445 === Protocol "6to4" (IPv6-in-IPv4 Tunnel) ===
446
447 *CAUTION*: The package '6to4' must be installed to use this protocol.
448
449 [cols="4*1,4",options="header"]
450 |====
451 | Name | Type | Required | Default | Description
452 | 'ipaddr' | IPv4 address | no | Current WAN IPv4 address | Local IPv4 endpoint address
453 | 'defaultroute' | boolean | no | '1' | Whether to create an IPv6 default route over the tunnel
454 | 'ttl' | integer | no | '64' | TTL used for the tunnel interface
455 | 'tos' | string | no | _(none)_ | Type Of Service : either "inherit" (the outer header inherits the value of the inner header) or an hexadecimal value
456 | 'mtu' | integer | no | '1280' | MTU used for the tunnel interface
457 | 'metric' | integer | no | '0' | Specifies the default route metric to use
458 | '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.
459 | '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'.
460 | 'adv_valid_lifetime' | integer | no | '300' | (deprecated) Overrides the advertised valid prefix lifetime, in seconds
461 | 'adv_preferred_lifetime' | integer | no | '120' | (deprecated) Overrides the advertised preferred prefix lifetime, in seconds
462 |====
463
464 **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'
465
466 **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)
467
468 === Protocol "6rd" (IPv6 rapid deployment) ===
469
470 *CAUTION*: The package '6rd' must be installed to use this protocol.
471
472 *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.
473
474 [cols="4*1,4",options="header"]
475 |====
476 | Name | Type | Required | Default | Description
477 | 'peeraddr' | IPv4 address | yes | no | 6rd - Gateway
478 | 'ipaddr' | IPv4 address | no | Current WAN IPv4 address | Local IPv4 endpoint address
479 | 'ip6prefix' | IPv6 prefix (without length) | yes | no | 6rd-IPv6 Prefix
480 | 'ip6prefixlen' | IPv6 prefix length | yes | no | 6rd-IPv6 Prefix length
481 | 'ip4prefixlen' | IPv6 prefix length | no | 0 | IPv4 common prefix
482 | 'defaultroute' | boolean | no | '1' | Whether to create an IPv6 default route over the tunnel
483 | 'ttl' | integer | no | '64' | TTL used for the tunnel interface
484 | 'tos' | string | no | _(none)_ | Type Of Service : either "inherit" (the outer header inherits the value of the inner header) or an hexadecimal value
485 | 'mtu' | integer | no | '1280' | MTU used for the tunnel interface
486 |====
487
488 **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'.
489
490 **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).
491
492
493 === Protocol "dslite" (Dual-Stack Lite) ===
494
495 *CAUTION*: The package 'ds-lite' must be installed to use this protocol.
496
497 [cols="4*1,4",options="header"]
498 |====
499 | Name | Type | Required | Default | Description
500 | 'peeraddr' | IPv6 address | yes | no | DS-Lite AFTR address
501 | 'ip6addr' | IPv6 address | no | Current WAN IPv6 address | Local IPv6 endpoint address
502 | 'tunlink' | Logical Interface | no | Current WAN interface | Tunnel base interface
503 | 'defaultroute' | boolean | no | '1' | Whether to create an IPv6 default route over the tunnel
504 | 'ttl' | integer | no | '64' | TTL used for the tunnel interface
505 | 'mtu' | integer | no | '1280' | MTU used for the tunnel interface
506 |====
507
508 *CAUTION*: ds-lite operation requires that IPv4 NAT is disabled. You should adjust your settings in /etc/config/firewall accordingly.
509
510 **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'.
511
512
513 === Protocol "l2tp" (PPP over L2TP Pseudowire Tunnel) ===
514
515 *CAUTION*: The package 'xl2tpd' must be installed to use this protocol.
516
517 Most options are similar to protocol "ppp".
518
519 [cols="4*1,4",options="header"]
520 |====
521 | Name | Type | Required | Default | Description
522 | '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
523 | 'username' | string | no | _(none)_ | Username for PAP/CHAP authentication
524 | 'password' | string | yes if 'username' is provided | _(none)_ | Password for PAP/CHAP authentication
525 | 'ipv6' | bool | no | 0 | Enable IPv6 on the PPP link (IPv6CP)
526 | 'mtu' | int | no | 'pppd' default | Maximum Transmit/Receive Unit, in bytes
527 | 'keepalive' | string | no | _(none)_ | Number of unanswered echo requests before considering the peer dead. The interval between echo requests is 5 seconds.
528 | '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
529 | 'pppd_options' | string | no | _(none)_ | Additional options to pass to 'pppd'
530 |====
531
532 The name of the physical interface will be "l2tp-<logical interface name>".
533
534 === Protocol "relay" (Relayd Pseudo Bridge) ===
535
536 *CAUTION*: The package 'relayd' must be installed to use this protocol.
537
538 [cols="4*1,4",options="header"]
539 |====
540 | Name | Type | Required | Default | Description
541 | 'network' | list of _logical interface names_ | yes | _(none)_ | Specifies the networks between which traffic is relayed
542 | 'gateway' | IPv4 address | no | _(network default)_ | Override the gateway address sent to clients within DHCP responses
543 | 'expiry' | integer | no | '30' | Host expiry timeout in seconds
544 | 'retry' | integer | no | '5' | Number of ARP ping retries before a host is considered dead
545 | 'table' | integer | no | '16800' | Table ID for automatically added routes
546 | 'forward_bcast' | boolean | no | '1' | Enables forwarding of broadcast traffic, '0' disables it
547 | 'forward_dhcp' | boolean | no | '1' | Enables forwarding of DHCP requests and responses, '0' disables it
548 |====
549
550
551 === Common options for GRE protocols ===
552
553 *CAUTION*: The package 'gre' must be installed to use GRE. Additionally, you need 'kmod-gre' and/or 'kmod-gre6'.
554
555 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".
556
557 All four protocols accept the following common options:
558
559 [cols="4*1,4",options="header"]
560 |====
561 | Name | Type | Required | Default | Description
562 | 'mtu' | integer | no | 1280 | MTU
563 | 'ttl' | integer | no | 64 | TTL of the encapsulating packets
564 | 'tunlink' | logical interface name | no | _(none)_ | Bind the tunnel to this interface ('dev' option of "ip tunnel")
565 | 'zone' | zone name | no | "wan" | Firewall zone to which the interface will be added
566 | '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
567 | 'ikey' | integer | no | 0 | key for incoming packets
568 | 'okey' | integer | no | 0 | key for outgoing packets
569 | 'icsum' | boolean | no | false | require incoming checksum
570 | 'ocsum' | boolean | no | false | compute outgoing checksum
571 | 'iseqno' | boolean | no | false | require incoming packets serialisation
572 | 'oseqno' | boolean | no | false | perform outgoing packets serialisation
573 |====
574
575 === Protocol "gre" (GRE tunnel over IPv4) ===
576
577 The following options are supported, in addition to all common options above:
578
579 [cols="4*1,4",options="header"]
580 |====
581 | Name | Type | Required | Default | Description
582 | 'ipaddr' | IPv4 address | no | WAN IP | Local endpoint
583 | 'peeraddr' | IPv4 address | yes | _(none)_ | Remote endpoint
584 | 'df' | boolean | no | true | Set "Don't Fragment" flag on encapsulating packets
585 |====
586
587 === Protocol "gretap" (Ethernet GRE tunnel over IPv4) ===
588
589 The following options are supported, in addition to all common options above:
590
591 [cols="4*1,4",options="header"]
592 |====
593 | Name | Type | Required | Default | Description
594 | 'ipaddr' | IPv4 address | no | WAN IP | Local endpoint
595 | 'peeraddr' | IPv4 address | yes | _(none)_ | Remote endpoint
596 | 'df' | boolean | no | true | Set "Don't Fragment" flag on encapsulating packets
597 | 'network' | logical interface name | no | _(none)_ | Logical network to which the tunnel will be added (bridged)
598 |====
599
600 === Protocol "grev6" (GRE tunnel over IPv6) ===
601
602 The following options are supported, in addition to all common options above:
603
604 [cols="4*1,4",options="header"]
605 |====
606 | Name | Type | Required | Default | Description
607 | 'ip6addr' | IPv6 address | no | WAN IP | Local endpoint
608 | 'peer6addr' | IPv6 address | yes | _(none)_ | Remote endpoint
609 | '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
610 |====
611
612 === Protocol "grev6tap" (Ethernet GRE tunnel over IPv6) ===
613
614 The following options are supported, in addition to all common options above:
615
616 [cols="4*1,4",options="header"]
617 |====
618 | Name | Type | Required | Default | Description
619 | 'ip6addr' | IPv6 address | no | WAN IP | Local endpoint
620 | 'peer6addr' | IPv6 address | yes | _(none)_ | Remote endpoint
621 | '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
622 | 'network' | logical interface name | no | _(none)_ | Logical network to which the tunnel will be added (bridged)
623 |====
624
625
626
627 === Protocol "vti" (VTI tunnel over IPv4) ===
628
629 VTI Tunnels are IPsec policies with a fwmark set. The traffic is redirected to the matching VTI interface.
630
631 [cols="4*1,4",options="header"]
632 |====
633 | Name | Type | Required | Default | Description
634 | 'ipaddr' | IPv4 address | no | WAN IP | Local endpoint
635 | 'peeraddr' | IPv4 address | yes | _(none)_ | Remote endpoint
636 | 'mtu' | integer | no | 1280 | MTU
637 | 'tunlink' | logical interface name | no | _(none)_ | Bind the tunnel to this interface ('dev' option of "ip tunnel")
638 | 'zone' | zone name | no | "wan" | Firewall zone to which the interface will be added
639 | 'ikey' | integer | no | 0 | key/fwmark for incoming packets
640 | 'okey' | integer | no | 0 | key/fwmark for outgoing packets
641 |====
642
643 === Protocol "vtiv6" (VTI tunnel over IPv6) ===
644
645 The following options are supported, in addition to all common options above:
646
647 [cols="4*1,4",options="header"]
648 |====
649 | Name | Type | Required | Default | Description
650 | 'ip6addr' | IPv6 address | no | WAN IP | Local endpoint
651 | 'peer6addr' | IPv6 address | yes | _(none)_ | Remote endpoint
652 | 'mtu' | integer | no | 1280 | MTU
653 | 'tunlink' | logical interface name | no | _(none)_ | Bind the tunnel to this interface ('dev' option of "ip tunnel")
654 | 'zone' | zone name | no | "wan" | Firewall zone to which the interface will be added
655 | 'ikey' | integer | no | 0 | key/fwmark for incoming packets
656 | 'okey' | integer | no | 0 | key/fwmark for outgoing packets
657 |====
658
659 === Devices
660 A minimal device declaration consists of the following lines:
661
662 ----
663 config device 'eth0.106'
664 option type '8021q'
665 option name 'eth0.106'
666 option ifname 'eth0'
667 option vid '106'
668 ----
669 === VLAN Interfaces ===
670 VLAN Interfaces may be configured also. If not, they are created on the fly by netifd. Defining VLANs gives more options.
671 The following options are supported:
672
673 [cols="4*1,4",options="header"]
674 |====
675 | Name | Type | Required | Default | Description
676 | 'type' | VLAN Type | no | 802.1q | VLAN type, possible values: 8021q or 8021ad
677 | 'name' | Name | yes | _(none)_ | Name of device, i.e. eth0.5 or vlan5
678 | 'ifname' | Parent interface | yes | _(none)_ | Name of parent/base interface, i.e. eth0
679 | 'vid' | VLAN Id | yes | _(none)_ | VLAN Id
680 | 'macaddr' | MAC | no | _(none)_ | MAC of new interface
681 |====
682
683 MAC address option is send upstream but not merged at time of writng.
684 === ATM Bridges (Ethernet over ATM AAL5)
685
686 *CAUTION*: The package 'br2684ctl' must be installed to use Ethernet over AAL5.
687
688 ATM bridges use a special config section called 'atm-bridge'.
689 Each 'atm-bridge' section maps the specified ATM curcuit an 'atm#' pseudo ethernet device which can
690 be used for example in conjunction with 'pppoe' to establish a DSL connection to the ISP.
691
692 A typical bridge section looks like this:
693 ----
694 config atm-bridge
695 option unit '0'
696 option vpi '8'
697 option vci '35'
698 ----
699
700 * Unit '0' will let 'br2684ctl' create a 'nas0' pseudo device
701 * VPI '8' and VCI '35' specifies the circuit to bridge. Those values are ISP dependant.
702
703 The 'atm-bridge' section allows the following options:
704
705 [cols="4*1,4",options="header"]
706 |====
707 | Name | Type | Required | Default | Description
708 | 'unit' | number | yes | '0' | Specifies the br2684 interface number. If ommitted, '0' is assumed which would result in a 'nas0' pseudo interface.
709 | 'vci' | number | no | '35' | PPPoA VCI
710 | 'vpi' | number | no | '8' | PPPoA VPI
711 | '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
712 | 'encaps' | string | no | 'llc' | PPPoA encapsulation mode: 'llc' (LLC) or 'vc' (VC)
713 | 'payload' | string | no | 'bridged' | PPPoA forwarding mode: 'routed' or 'bridged'
714 |====
715
716 === DSL / VDSL
717
718 *CAUTION*: This currently only works on devices based on lantiq SoCs.
719
720 (V)DSL uses a special config section called 'dsl', which typically looks like this:
721 ----
722 config vdsl 'dsl'
723 option annex 'b'
724 option firmware '/lib/firmware/vdsl.bin'
725 option tone 'bv'
726 option xfer_mode 'atm'
727 ----
728
729 The 'dsl' section allows the following options:
730
731 [cols="4*1,4",options="header"]
732 |====
733 | Name | Type | Required | Default | Description
734 | '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
735 | '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 **
736 | '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**
737 | '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.**
738 |====
739
740 === Lantiq xDSL firmware ===
741
742 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:
743
744 * dsl-vrx200-firmware-xdsl-a
745 * dsl-vrx200-firmware-xdsl-b
746
747 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/[]
748
749 === Aliases
750
751 Basically create an 'interface' section per IP, but alias interfaces may NOT be of type bridge
752
753 * For non-bridged interfaces (physdev , that is physical interfaces) the 'ifname' is the <interface-of-network-for-same-phydev>
754 * 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).
755
756 A minimal alias definition for a bridged interface might be (for a scenario without vlans):
757 ----
758 config interface lan
759 option 'ifname' 'eth0'
760 option 'type' 'bridge'
761 option 'proto' 'static'
762 option 'ipaddr' '192.168.1.1'
763 option 'netmask' '255.255.255.0'
764 ----
765
766 ----
767 config interface lan2
768 option 'ifname' 'br-lan'
769 option 'proto' 'static'
770 option 'ipaddr' '10.0.0.1'
771 option 'netmask' '255.255.255.0'
772 ----
773
774 or for a non-bridge interface
775 ----
776 config interface lan
777 option 'ifname' 'eth0'
778 option 'proto' 'static'
779 option 'ipaddr' '192.168.1.1'
780 option 'netmask' '255.255.255.0'
781 ----
782
783 ----
784 config interface lan2
785 option 'ifname' 'eth0'
786 option 'proto' 'static'
787 option 'ipaddr' '10.0.0.1'
788 option 'netmask' '255.255.255.0'
789 ----
790
791 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').
792
793 === Aliases: notes ===
794
795 On openwrt 12.09, a lan interface that is first defined as dhcp interface
796 and then has aliases with static ip address could cause problems
797 in routing the lan traffic through the wan zone using the basic lan-wan forwarding provided by openwrt.
798 A solution is: having the basic interface with static address and aliases with dhcp protocol.
799
800 Another note is related to 'how to refer to the ifname of an interface'.
801 Normally the ifname is 'br-wan' if the interface 'wan' is bridged,
802 else is 'ifname <nic_device>' . Another way to avoid to list always the same
803 device is using 'ifname @interface'. In this way, even if the wan interface
804 is not a bridge, one can refer to the physical device used by the wan interface
805 indirectly.
806
807 === IPv4 Routes
808
809 Static _IPv4 routes_ can be defined on specific interfaces using 'route' sections. As for _aliases_, multiple sections can be attached to an interface.
810
811 A minimal example looks like this:
812
813 ----
814 config 'route' 'name_your_route'
815 option 'interface' 'lan'
816 option 'target' '172.16.123.0'
817 option 'netmask' '255.255.255.0'
818 option 'gateway' '172.16.123.100'
819 ----
820
821 * 'lan' is the _logical interface name_ of the parent interface
822 * '172.16.123.0' is the _network address_ of the route
823 * '255.255.255.0' specifies the _route netmask_
824
825 Legal options for _IPv4 routes_ are:
826
827 [cols="4*1,4",options="header"]
828 |====
829 | Name | Type | Required | Default | Description
830 | '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
831 | 'target' | ip address | yes | _(none)_ | Network address
832 | 'netmask' | netmask | no | _(none)_ | Route netmask. If omitted, '255.255.255.255' is assumed which makes 'target' a _host address_
833 | '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
834 | 'metric' | number | no | '0' | Specifies the _route metric_ to use
835 | 'mtu' | number | no | _interface MTU_ | Defines a specific MTU for this route
836 | '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
837 | 'source' | ip address | no | _(none)_ | The preferred source address when sending to destinations covered by the target
838 | 'onlink' | boolean | no | '0' | When enabled gateway is on link even if the gateway does not match any interface prefix
839 | 'type' | string | no | 'unicast' | One of the types outlined in the Routing Types table below
840 |====
841
842 To disable a route quickly, the option 'enabled' is not available. Just rewrite the 'route' config section as 'disabled_route' like:
843 ----
844 config 'disabled_route' 'name_your_route'
845 ...lines...
846 ----
847 and it will be recognized by the uci parser but not applied by the '/etc/init.d/network' script.
848
849 *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.
850 === IPv6 Routes
851
852 _IPv6 routes_ can be specified as well by defining one or more 'route6' sections.
853
854 A minimal example looks like this:
855
856 ----
857 config 'route6'
858 option 'interface' 'lan'
859 option 'target' '2001:0DB8:100:F00:BA3::1/64'
860 option 'gateway' '2001:0DB8:99::1'
861 ----
862
863 * 'lan' is the _logical interface name_ of the parent interface
864 * '2001:0DB8:100:F00:BA3::1/64' is the routed _IPv6 subnet_ in CIDR notation
865 * '2001:0DB8:99::1' specifies the _IPv6 gateway_ for this route
866
867 Legal options for _IPv6 routes_ are:
868
869 [cols="4*1,4",options="header"]
870 |====
871 | Name | Type | Required | Default | Description
872 | '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
873 | 'target' | ipv6 address | yes | _(none)_ | IPv6 network address
874 | 'gateway' | ipv6 address | no | _(none)_ | IPv6 gateway. If omitted, the 'gateway' from the parent interface is taken
875 | 'metric' | number | no | '0' | Specifies the _route metric_ to use
876 | 'mtu' | number | no | _interface MTU_ | Defines a specific MTU for this route
877 | '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
878 | 'source' | ip address | no | _(none)_ | The preferred source address when sending to destinations covered by the target
879 | 'onlink' | boolean | no | '0' | When enabled gateway is on link even if the gateway does not match any interface prefix
880 | 'type' | string | no | 'unicast' | One of the types outlined in the Routing Types table below
881 |====
882
883 === Routing Types ===
884
885 [cols="1,4",options="header"]
886 |====
887 | Type | Description
888 | 'unicast' | the route entry describes real paths to the destinations covered by the route prefix.
889 | 'local' | the destinations are assigned to this host. The packets are looped back and delivered locally.
890 | 'broadcast' | the destinations are broadcast addresses. The packets are sent as link broadcasts.
891 | 'multicast' | a special type used for multicast routing. It is not present in normal routing tables.
892 | 'unreachable' | these destinations are unreachable. Packets are discarded and the ICMP message host unreachable is generated. The local senders get an EHOSTUNREACH error.
893 | 'prohibit' | these destinations are unreachable. Packets are discarded and the ICMP message communication administratively prohibited is generated. The local senders get an EACCES error.
894 | 'blackhole' | these destinations are unreachable. Packets are discarded silently. The local senders get an EINVAL error.
895 | '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.
896 |====
897
898
899 === IP rules
900
901 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.
902
903 A simple IPv4 rule may look like:
904
905 ----
906 config rule
907 option mark '0xFF'
908 option in 'lan'
909 option dest '172.16.0.0/16'
910 option lookup '100'
911 ----
912
913 * '0xFF' is a fwmark to be matched
914 * 'lan' is the incoming _logical interface name_
915 * '172.16.0.0/16' is the destination subnet to match
916 * '100' is the routing table ID to use for the matched traffic
917
918 Similary, an IPv6 rule looks like:
919
920 ----
921 config rule6
922 option in 'vpn'
923 option dest 'fdca:1234::/64'
924 option action 'prohibit'
925 ----
926
927 * 'vpn' is the incoming _logical interface name_
928 * 'fdca:1234::/64' is the destination subnet to match
929 * 'prohibit' is a routing action to take
930
931 The options below are defined for _IP rule_ ('rule' and 'rule6') sections:
932
933 [cols="4*1,4",options="header"]
934 |====
935 | Name | Type | Required | Default | Description
936 | 'in' | string | no | _(none)_ | Specifies the incoming _logical interface name_
937 | 'out' | string | no | _(none)_ | Specifies the outgoing _logical interface name_
938 | 'src' | ip subnet | no | _(none)_ | Specifies the source subnet to match (CIDR notation)
939 | 'dest' | ip subnet | no | _(none)_ | Specifies the destination subnet to match (CIDR notation)
940 | 'tos' | integer | no | _(none)_ | Specifies the TOS value to match in IP headers
941 | '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
942 | 'invert' | boolean | no | '0' | If set to '1', the meaning of the match options is inverted
943 | '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
944 | '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
945 | 'goto' | rule index | ::: | ::: | The rule target is a jump to another rule specified by its 'priority' value
946 | 'action' | string | ::: | ::: | The rule target is one of the routing actions outlined in the table below
947 |====
948
949 === Routing Actions ===
950
951 [cols="1,4",options="header"]
952 |====
953 | Action | Description
954 | 'prohibit' | When reaching the rule, respond with _ICMP prohibited_ messages and abort route lookup
955 | 'unreachable' | When reaching the rule, respond with _ICMP unreachable_ messages and abort route lookup
956 | 'blackhole' | When reaching the rule, drop packet and abort route lookup
957 | 'throw' | Stop lookup in the current routing table even if a default route exists
958 |====
959
960 == Examples
961
962 Below are a few examples for special, non-standard interface configurations.
963
964 === Bridge without IP
965
966 ----
967 config 'interface' 'example'
968 option 'type' 'bridge'
969 option 'proto' 'none'
970 option 'ifname' 'eth0 eth1'
971 option 'auto' '1'
972 ----
973
974 === DHCP without default gateway
975
976
977 ----
978 config 'interface' 'example'
979 option 'proto' 'dhcp'
980 option 'ifname' 'eth0'
981 option 'defaultroute' '0'
982 ----
983
984 === DHCP and IPv6
985
986 ----
987 config 'interface' 'example'
988 option 'proto' 'dhcp'
989 option 'ifname' 'eth0'
990
991 config 'alias'
992 option 'interface' 'example'
993 option 'proto' 'static'
994 option 'ip6addr' '2001:0DB8:100:F00:BA3::1'
995 ----
996
997 === Static IP configuration with multiple dnses
998
999 ----
1000 config 'interface' 'example'
1001 option 'proto' 'static'
1002 option 'ifname' 'eth0'
1003 option 'ipaddr' '192.168.1.200'
1004 option 'netmask' '255.255.255.0'
1005 list 'dns' '192.168.1.1'
1006 list 'dns' '192.168.10.1'
1007 # the priority is: the last dns listed will be the first one
1008 # to be chosen for the name resolution.
1009 ----
1010
1011 *CAUTION*: Openwrt will use the new dns configured only after a reboot or a '/etc/init.d/dnsmasq restart'.
1012
1013 === Static IP configuration and default gateway with non-zero metric
1014
1015 ----
1016 config 'interface' 'example'
1017 option 'proto' 'static'
1018 option 'ifname' 'eth0'
1019 option 'ipaddr' '192.168.1.200'
1020 option 'netmask' '255.255.255.0'
1021 option 'dns' '192.168.1.1'
1022
1023 config 'route'
1024 option 'interface' 'example'
1025 option 'target' '0.0.0.0'
1026 option 'netmask' '0.0.0.0'
1027 option 'gateway' '192.168.1.1'
1028 option 'metric' '100'
1029 ----
1030
1031 === PPtP-over-PPPoE internet connection
1032
1033 ----
1034 config 'interface' 'wan'
1035 option 'proto' 'pppoe'
1036 option 'ifname' 'eth1'
1037 option 'username' 'user'
1038 option 'password' 'pass'
1039 option 'timeout' '10'
1040
1041 config 'interface' 'vpn'
1042 option 'proto' 'pptp'
1043 option 'ifname' 'vpn'
1044 option 'username' 'vpnuser'
1045 option 'password' 'vpnpass'
1046 option 'server' 'vpn.example.org'
1047 ----
1048
1049 *CAUTION*: Additionally the "wan" firewall zone must include both interfaces in '/etc/config/firewall':
1050
1051 ----
1052 config 'zone'
1053 option 'name' 'wan'
1054 option 'network' 'wan vpn' # Important
1055 option 'input' 'REJECT'
1056 option 'forward' 'REJECT'
1057 option 'output' 'ACCEPT'
1058 option 'masq' '1'
1059 ----
1060
1061 === PPPoA ADSL internet connection
1062
1063 ----
1064 config adsl-device 'adsl'
1065 option fwannex 'a'
1066 option annex 'a'
1067
1068 config interface 'wan'
1069 option proto 'pppoa'
1070 option username 'jbloggs@plusdsl.net'
1071 option password 'XXXXXXXXX'
1072 option vpi '0'
1073 option vci '38'
1074 option encaps 'vc'
1075 ----
1076
1077 === listing an interface created by software on the router, like vpn
1078
1079 For example, a vpn interface is normally "tun0". To list it in the uci config files (and therefore in luci):
1080 ----
1081 config interface 'tun0'
1082 option ifname 'tun0'
1083 option proto 'none'
1084 ----
1085
1086 === Static IPv6-in-IPv4 tunnel
1087
1088 The example below illustrates a static tunnel configuration in '/etc/config/network' file for the Hurricane Electric (he.net) broker.
1089 Option 'ipaddr' specifies the local IPv4 address, 'peeraddr' is the broker IPv4 address and 'ip6addr' the local IPv6 address routed via the tunnel.
1090
1091 ----
1092 config 'interface' 'henet'
1093 option 'proto' '6in4'
1094 option 'ipaddr' '178.24.115.19'
1095 option 'peeraddr' '216.66.80.30'
1096 option 'ip6addr' '2001:0DB8:1f0a:1359::2/64'
1097 ----
1098
1099 *CAUTION*: You should also add an address from your routed IPv6 network to the "lan" interface.
1100
1101 *CAUTION*: To apply IPv6 firewall rules to the tunnel interface, add it to the "wan" zone in '/etc/config/firewall':
1102
1103 ----
1104 config 'zone'
1105 option 'name' 'wan'
1106 option 'network' 'wan henet' # Important
1107 option 'input' 'REJECT'
1108 option 'forward' 'REJECT'
1109 option 'output' 'ACCEPT'
1110 option 'masq' '1'
1111 ----
1112
1113 *CAUTION*: If you define a new, dedicated zone just for the tunnel interface,
1114 make sure to set 'option conntrack 1' in order to force enabling connection tracking,
1115 otherwise unidirectional forwarding rules will not work.
1116
1117 *CAUTION*: Don't forget to set up forwarding rules between the LAN and the tunnel if you want to route IPv6 traffic between them.
1118
1119 === Setup behind one-to-one NAT ===
1120
1121 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:
1122
1123 ----
1124 . /lib/functions/network.sh; network_get_ipaddr ip wan; echo $ip
1125 ----
1126
1127 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:
1128
1129 ----
1130 config 'interface' 'henet'
1131 option 'proto' '6in4'
1132 option 'peeraddr' '216.66.80.30'
1133 option 'ip6addr' '2001:0DB8:1f0a:1359::2/64'
1134 ----
1135
1136 === Dynamic IPv6-in-IPv4 tunnel (HE.net only)
1137
1138 The example below illustrates a dynamic tunnel configuration for the Hurricane Electric (he.net) broker with enabled IP update.
1139 The local IPv4 address is automatically determined and tunnelid, username and password are provided for IP update.
1140
1141 ----
1142 config 'interface' 'henet'
1143 option 'proto' '6in4'
1144 option 'peeraddr' '216.66.80.30'
1145 option 'ip6addr' '2001:0DB8:1f0a:1359::2/64'
1146 option 'tunnelid' '12345'
1147 option 'username' 'myusername'
1148 option 'password' '098f6bcd4621d373cade4e832627b4f6'
1149 ----
1150
1151 === L2TPv3 Pseudowire bridged to LAN
1152
1153 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'.
1154
1155 ----
1156 config 'interface' 'lan'
1157 option 'proto' 'l2tp'
1158 option 'type' 'bridge'
1159 option 'ifname' 'eth0'
1160 option 'ipaddr' '192.168.1.1'
1161 option 'netmask' '255.255.255.0'
1162 option 'localaddr' '178.24.154.19'
1163 option 'peeraddr' '89.44.33.61'
1164 option 'encap' 'udp'
1165 option 'sport' '4000'
1166 option 'dport' '5410'
1167 ----
1168
1169 === Relay between LAN and Wireless Station
1170
1171 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.
1172
1173 Wireless configuration (excerpt):
1174
1175 ----
1176 config wifi-iface
1177 option 'device' 'radio0'
1178 option 'mode' 'sta'
1179 option 'ssid' 'Some Wireless Network'
1180 option 'encryption' 'psk2'
1181 option 'key' '12345678'
1182 option 'network' 'wwan'
1183 ----
1184
1185 Network configuration (excerpt):
1186
1187 *CAUTION*: Note that the LAN subnet must be different from the one used by wireless network's DHCP.
1188
1189 ----
1190 config 'interface' 'lan'
1191 option 'ifname' 'eth0.1'
1192 option 'proto' 'static'
1193 option 'ipaddr' '192.168.1.1'
1194 option 'netmask' '255.255.255.0'
1195
1196 config 'interface' 'wwan'
1197 option 'proto' 'dhcp'
1198
1199 config 'interface' 'stabridge'
1200 option 'proto' 'relay'
1201 option 'network' 'lan wwan'
1202 ----
1203
1204 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:
1205
1206 ----
1207 config 'zone'
1208 option 'name' 'lan'
1209 option 'network' 'lan wwan' # Important
1210 option 'input' 'ACCEPT'
1211 option 'forward' 'ACCEPT' # Important
1212 option 'output' 'ACCEPT'
1213 ----
1214
1215 === Static addressing of a GRE tunnel
1216
1217 Create a GRE tunnel with static address 10.42.0.253/30, adding it to an existing firewall zone called 'tunnels':
1218
1219 ----
1220 config interface mytunnel
1221 option proto gre
1222 option zone tunnels
1223 option peeraddr 198.51.100.42
1224
1225 config interface mytunnel_addr
1226 option proto static
1227 option ifname @mytunnel
1228 option ipaddr 10.42.0.253
1229 option netmask 255.255.255.252
1230 # Fixes IPv6 multicast (long-standing bug in kernel).
1231 # Useful if you run Babel or OSPFv3.
1232 option ip6addr 'fe80::42/64'
1233 ----
1234
1235 == Network management
1236
1237 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.
1238
1239 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.
1240
1241 == Determining Linux interface names
1242
1243 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.
1244
1245 ----
1246 WANIF=$(uci -P/var/state get network.wan.ifname)
1247 iptables -I INPUT -i $WANIF -p tcp --dport 22 -j ACCEPT
1248 ----
1249
1250 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].
1251 Use /lib/functions/network.sh:
1252
1253 ----
1254 source /lib/functions/network.sh
1255
1256 if network_get_ipaddr addr "wan"; then
1257 echo "IP is $addr"
1258 fi
1259 ----
1260
1261 == Multiple IP addresses
1262
1263 Assigning multiple ip addresses to the same interface:
1264 ----
1265 config interface foo
1266 option ifname eth1
1267 list ipaddr 10.8.0.1/24
1268 list ipaddr 10.9.0.1/24
1269 list ip6addr fdca:abcd::1/64
1270 list ip6addr fdca:cdef::1/64
1271 ----
1272
1273 Specifying multiple interfaces sharing the same device:
1274
1275 ----
1276 config interface foo
1277 option ifname eth1
1278 option ipaddr 10.8.0.1
1279 option netmask 255.255.255.0
1280 option ip6addr fdca:abcd::1/64
1281
1282 config interface foo2
1283 option ifname eth1
1284 option ipaddr 10.9.0.1
1285 option netmask 255.255.255.0
1286 option ip6addr fdca:cdef::1/64
1287 ----
1288