Differences

This shows you the differences between two versions of the page.

doc:uci:network [2013/01/15 15:01]
steven
doc:uci:network [2014/02/24 18:35] (current)
hnyman Add he.net updatekey info for 6in4
Line 1: Line 1:
====== Network configuration ====== ====== Network configuration ======
-The central network configuration is located in ''/etc/config/network''. +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//. After editing and saving ''/etc/config/network'' you need to execute <code>/etc/init.d/network reload</code> to stop and restart the network before any changes take effect. Rebooting the router is not necessary.
-<code> +
-config interface loopback +
-        option ifname  lo +
-        option proto    static +
-        option ipaddr  127.0.0.1 +
-        option netmask  255.0.0.0+
-config interface lan +  * https://dev.openwrt.org/browser/branches/attitude_adjustment/package/base-files/files/etc/config/network 
-        option ifname  eth0 +  * https://dev.openwrt.org/browser/trunk/package/base-files/files/etc/config/network
-        option type    bridge +
-        option proto    static +
-        option ipaddr   192.168.1.1 +
-       option netmask 255.255.255.0+
-config interface wan +Feel free to inform yourself about [[doc/techref/netifd|netifd]] (Network Interface Daemon).
-        option 'ifname' 'eth0.2' +
-        option 'proto' 'pppoe' +
-        option 'username' 'szabozsolt-em' +
-        option 'password' 'M3IuWBt4'+
-config switch eth0 +===== Sections =====
-        option enable_vlan      1+
-config switch_vlan +Below is an overview of the section types that may be defined in the network configuration. 
-        option device  eth0 +A minimal network configuration for a router usually consists of at least two //interfaces// (''lan'' and ''wan'') and a //switch// section if applicable.
-        option vlan    1 +
-        option ports    "0 1 2 3 4" +
-</code> +
-This is the default configuration file for Backfire on a D-link Dir-601 Rev.A and typical example of a basic network setup. +
-This configuration file is responsible for defining //switch VLANs//, //interface configurations// and //network routes//.+
-**''Hint:''** After editing and saving ''/etc/config/network'' you need to execute +==== Global Settings ==== 
-<code> +:!: The globals section is available in Barrier Breaker and later releases.
-/etc/init.d/network restart +
-</code> +
-to stop and restart the network before any changes take effect. Rebooting the router will have the same effect but is not necessary.+
-===== Sections =====+The ''globals'' section contains interface-independent options affecting the network configuration in general. 
 + 
 +^ Name ^ Type ^ Required ^ Default ^ Description ^ 
 +| ''ula_prefix'' | IPv6-prefix | no | //(none)// | IPv6 [[wp>Unique local address|ULA]]-Prefix for this device |
-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. 
==== Switch ==== ==== Switch ====
 +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 has a programmable switch, therefore this section might not be present on some platforms. Please also note, that some switches only support 4Bit-VLANs.
-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 has a programmable switch, therefore this section might not be present on some platforms. +There are currently two different configuration formats in use, one for the legacy ''/proc/switch/'' API and one for the newer ''[[doc/techref/swconfig|swconfig]]''-based switch configuration.
- +
-There are currently two different configuration formats in use, one for the legacy ''/proc/switch/'' API and one for the newer //swconfig// based switch infrastructure.+
=== /proc/switch === === /proc/switch ===
- +This variant is actually only found on Broadcom devices like the WRT54GL.
-This variant is only found on Broadcom devices like the WRT54GL.+
A typical configuration for it looks like this: A typical configuration for it looks like this:
Line 63: Line 39:
=== swconfig === === swconfig ===
 +The newer ''[[doc/techref/swconfig|swconfig]]''-framework is intended to replace the legacy switch configuration.
-The newer //swconfig// framework is intended to replace the legacy switch configuration. +Configuration for swconfig have a slightly different structure with one extra section per VLAN.
- +
-The typical filepath for the config is ''/etc/config/network'' +
- +
-//Swconfig// based configurations have a different structure with one extra section per vlan.+
The example below shows a typical configuration: The example below shows a typical configuration:
<code>config 'switch' 'eth0' <code>config 'switch' 'eth0'
Line 86: Line 59:
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. 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.
The complete layout is explained in the [[doc:uci:network::switch|switch documentation]]. The complete layout is explained in the [[doc:uci:network::switch|switch documentation]].
-==== Interfaces ==== 
 +
 +==== Interfaces ====
Sections of the type ''interface'' declare logical networks serving as containers for IP address settings, [[doc:uci:network#aliases|aliases]], [[doc:uci:network#ipv4.routes|routes]], physical interface names and [[doc:uci:firewall#zones|firewall rules]] - they play a central role within the OpenWrt configuration concept. Sections of the type ''interface'' declare logical networks serving as containers for IP address settings, [[doc:uci:network#aliases|aliases]], [[doc:uci:network#ipv4.routes|routes]], physical interface names and [[doc:uci:firewall#zones|firewall rules]] - they play a central role within the OpenWrt configuration concept.
Line 111: Line 85:
| ''3g'' | CDMA, UMTS or GPRS connection using an AT-style 3G modem |  ''comgt''  | | ''3g'' | CDMA, UMTS or GPRS connection using an AT-style 3G modem |  ''comgt''  |
| ''pptp'' | Connection via PPtP VPN |  ?  | | ''pptp'' | Connection via PPtP VPN |  ?  |
-| ''6in4'' | IPv6-in-IPv4 tunnel for use with Tunnel Brokers like HE.net |  ?  |+| ''6in4'' | IPv6-in-IPv4 tunnel forSuppresses DHCP-assigned default gateway if set to 0.0.0.0 use with Tunnel Brokers like HE.net |  ?  |
| ''6to4'' | Stateless IPv6 over IPv4 transport |  ?  | | ''6to4'' | Stateless IPv6 over IPv4 transport |  ?  |
| ''none'' | Unspecified protocol |  -  | | ''none'' | Unspecified protocol |  -  |
Line 122: Line 96:
^ Name ^ Type ^ Required ^ Default ^ Description ^ ^ Name ^ Type ^ Required ^ Default ^ Description ^
| ''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''// | | ''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''// |
-| ''type'' | string | no | //(none)// | If set to "bridge", a bridge containing the given //ifnames// is created |+| ''type'' | string | no | //(none)// | If set to "bridge", a bridge containing the given //ifnames// is created\\ [[https://forum.openwrt.org/viewtopic.php?pid=203784#p203784|Wlan interface names are not predictable, therfore you cannot reference them directly in the network config]] |
| ''stp'' | boolean | no | ''0'' | Only valid for type "bridge", enables the Spanning Tree Protocol | | ''stp'' | boolean | no | ''0'' | Only valid for type "bridge", enables the Spanning Tree Protocol |
 +| ''bridge_empty'' | boolean | no | ''0'' | Only valid for type "bridge", enables creating empty bridges |
| ''macaddr'' | mac address | no | //(none)// | Override MAC address of this interface | | ''macaddr'' | mac address | no | //(none)// | Override MAC address of this interface |
| ''mtu'' | number | no | //(none)// | Override the default MTU on this interface | | ''mtu'' | number | no | //(none)// | Override the default MTU on this interface |
| ''auto'' | boolean | no | ''0'' for proto ''none'', else ''1'' | Specifies whether to bring up interface on boot | | ''auto'' | boolean | no | ''0'' for proto ''none'', else ''1'' | Specifies whether to bring up interface on boot |
-| ''accept_ra'' | boolean | no | ''1'' for protocol ''dhcp'', else ''0'' | Specifies whether to accept IPv6 Router Advertisements on this interface | +| ''accept_ra'' | boolean | no | ''1'' for protocol ''dhcp'', else ''0'' | **deprecated:** Specifies whether to accept IPv6 Router Advertisements on this interface (On Attitude Adjustment 12.09 and earlier versions)
-| ''send_rs'' | boolean | no | ''1'' for protocol ''static'', else ''0'' | Specifies whether to send Router Solicitations on this interface |+| ''send_rs'' | boolean | no | ''1'' for protocol ''static'', else ''0'' | **deprecated:** Specifies whether to send Router Solicitations on this interface (On Attitude Adjustment 12.09 and earlier versions) |
=== Protocol "static" === === Protocol "static" ===
Line 139: Line 114:
| ''ip6addr'' | ipv6 address | yes, if no ''ipaddr'' is set | //(none)// | Assign given IPv6 address to this interface (CIDR notation) | | ''ip6addr'' | ipv6 address | yes, if no ''ipaddr'' is set | //(none)// | Assign given IPv6 address to this interface (CIDR notation) |
| ''ip6gw'' | ipv6 address | no | //(none)// | Assign given IPv6 default gateway to this interface | | ''ip6gw'' | ipv6 address | no | //(none)// | Assign given IPv6 default gateway to this interface |
-| ''ip6assign'' | prefix length | no | //(none)// | Delegate a prefix of given length to this interface (Barrier Breaker and later only) | +| ''ip6assign'' | prefix length | no | //(none)// | Delegate a [[[[network6#downstream.configuration.for.lan-interfaces|prefix of given length]] to this interface (Barrier Breaker and later only) | 
-| ''ip6prefix'' | ipv6 prefix | no | //(none)// | Routed IPv6 prefix for downstream interfaces (Barrier Breaker and later only) |+| ''ip6hint'' | prefix hint (hex) | no | //(none)// | [[network6#downstream.configuration.for.lan-interfaces|Hint the subprefix-ID]] that should be delegeted as hexadecimal number (Barrier Breaker and later only) |  
 +| ''ip6prefix'' | ipv6 prefix | no | //(none)// | IPv6 prefix routed here for use on other interfaces (Barrier Breaker and later only)
 +| ''ip6class'' | list of strings | no | //(none)// | Define the IPv6 prefix-classes this interface will accept |
| ''dns'' | list of ip addresses | no | //(none)// | DNS server(s) | | ''dns'' | list of ip addresses | no | //(none)// | DNS server(s) |
| ''metric'' | integer | no | ''0'' | Specifies the default route metric to use | | ''metric'' | integer | no | ''0'' | Specifies the default route metric to use |
Line 147: Line 124:
^ Name ^ Type ^ Required ^ Default ^ Description ^ ^ Name ^ Type ^ Required ^ Default ^ Description ^
-| ''gateway'' | string | no | //(none)// | Suppresses DHCP-assigned default gateway if set to 0.0.0.0 |+| ''<del>gateway</del>'' | <del>string</del> | <del>no</del> | <del>//(none)//</del> | <del>Suppresses DHCP-assigned default gateway if set to 0.0.0.0</del> \\ (deprecated) |
| ''broadcast'' | boolean | no | ''0'' | Enable the broadcast flag in DHCP requests, required for certain ISPs, e.g. Charter with DOCSIS 3 | | ''broadcast'' | boolean | no | ''0'' | Enable the broadcast flag in DHCP requests, required for certain ISPs, e.g. Charter with DOCSIS 3 |
| ''hostname'' | string | no | //(none)// | Hostname to include in DHCP requests | | ''hostname'' | string | no | //(none)// | Hostname to include in DHCP requests |
Line 154: Line 131:
| ''dns'' | list of ip addresses | no | //(none)// | Supplement DHCP-assigned DNS server(s), or use only these if peerdns is 0 | | ''dns'' | list of ip addresses | no | //(none)// | Supplement DHCP-assigned DNS server(s), or use only these if peerdns is 0 |
| ''peerdns'' | boolean | no | ''1'' | Use DHCP-provided DNS server(s) | | ''peerdns'' | boolean | no | ''1'' | Use DHCP-provided DNS server(s) |
 +| ''defaultroute'' | boolean | no | ''1'' | Whether to create a default route via the received gateway |
| ''metric'' | integer | no | ''0'' | Specifies the default route metric to use | | ''metric'' | integer | no | ''0'' | Specifies the default route metric to use |
| ''reqopts'' | list of strings | no | //(none)// | Specifies a list of additional DHCP options to request | | ''reqopts'' | list of strings | no | //(none)// | Specifies a list of additional DHCP options to request |
 +| ''iface6rd'' | logical interface | no | //(none)// | Logical interface template for auto-configuration of 6rd |
 +
 +**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.
=== Protocol "dhcpv6" === === Protocol "dhcpv6" ===
Line 163: Line 144:
^ Name ^ Type ^ Required ^ Default ^ Description ^ ^ Name ^ Type ^ Required ^ Default ^ Description ^
| ''reqaddress'' | [try,force,none] | no | try | Behaviour for requesting addresses | | ''reqaddress'' | [try,force,none] | no | try | Behaviour for requesting addresses |
-| ''reqprefix'' | [auto,no,0-64] | no | auto | Behaviour for requesting prefixes (numbers denote hinted prefix length) | +| ''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
-| ''clientid'' | string | no | //system default// | Override client identifier in DHCP requests |+| ''clientid'' | hexstring | no | //system default// | Override client identifier in DHCP requests
 +| ''ifaceid'' | ipv6 addr | no | //link-local identifier// | Override the interface identifier for adresses received via RA |
| ''dns'' | list of ip addresses | no | //(none)// | Supplement DHCP-assigned DNS server(s), or use only these if peerdns is 0 | | ''dns'' | list of ip addresses | no | //(none)// | Supplement DHCP-assigned DNS server(s), or use only these if peerdns is 0 |
| ''peerdns'' | boolean | no | ''1'' | Use DHCP-provided DNS server(s) | | ''peerdns'' | boolean | no | ''1'' | Use DHCP-provided DNS server(s) |
 +| ''defaultroute'' | boolean | no | ''1'' | Whether to create an IPv6 default route via the received gateway |
| ''reqopts'' | list of numbers | no | //(none)// | Specifies a list of additional DHCP options to request | | ''reqopts'' | list of numbers | no | //(none)// | Specifies a list of additional DHCP options to request |
 +| ''noslaaconly'' | boolean | no | ''0'' | Don't allow configuration via SLAAC (RAs) only (implied by reqprefix != no) |
 +| ''norelease'' | boolean | no | ''0'' | Don't send a RELEASE when the interface is brought down |
 +| ''ip6prefix'' | ipv6 prefix | no | //(none)// | Use an (additional) user-provided IPv6 prefix for distribution to clients |
 +| ''iface_dslite'' | logical interface | no | //(none)// | Logical interface template for auto-configuration of DS-Lite |
 +
 +**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.
=== Protocol "ppp" (PPP over Modem) === === Protocol "ppp" (PPP over Modem) ===
Line 272: Line 261:
| ''ttl'' | integer | no | ''64'' | TTL used for the tunnel interface | | ''ttl'' | integer | no | ''64'' | TTL used for the tunnel interface |
| ''mtu'' | integer | no | ''1280'' | MTU used for the tunnel interface | | ''mtu'' | integer | no | ''1280'' | MTU used for the tunnel interface |
-| ''wan_device'' | string | no | //(none)// | Interface from where client IPv4 endpoint address is derived (used for endpoint update)| 
| ''tunnelid'' | integer | no | //(none)// | HE.net global tunnel ID (used for endpoint update) | | ''tunnelid'' | integer | no | //(none)// | HE.net global tunnel ID (used for endpoint update) |
| ''username'' | string | no | //(none)// | HE.net user ID (used for endpoint update) | | ''username'' | string | no | //(none)// | HE.net user ID (used for endpoint update) |
| ''password'' | string | no | //(none)// | md5sum of HE.net password (used for endpoint update) | | ''password'' | string | no | //(none)// | md5sum of HE.net password (used for endpoint update) |
 +| ''updatekey'' | string | no | //(none)// | HE.net updatekey, overrides password (used for endpoint update) |
| ''metric'' | integer | no | ''0'' | Specifies the default route metric to use | | ''metric'' | integer | no | ''0'' | Specifies the default route metric to use |
**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''. **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''.
 +
 +**Note:** HE.net has introduced updatekey as default for new tunnels in February 2014. Support added to Openwrt trunk by r39646.
Line 290: Line 281:
| ''ttl'' | integer | no | ''64'' | TTL used for the tunnel interface | | ''ttl'' | integer | no | ''64'' | TTL used for the tunnel interface |
| ''mtu'' | integer | no | ''1280'' | MTU used for the tunnel interface | | ''mtu'' | integer | no | ''1280'' | MTU used for the tunnel interface |
-| ''adv_interface'' | string | no | ''lan'' | The //logical interface name// of the network the subnet should be advertised on. Multiple interface names can be given. | 
-| ''adv_subnet'' | hex number | no | ''1'' | 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''.  | 
-| ''adv_valid_lifetime'' | integer | no | ''300'' | Overrides the advertised valid prefix lifetime, in seconds (see also [[doc:uci:radvd#prefix|radvd prefix options]]) | 
-| ''adv_preferred_lifetime'' | integer | no | ''120'' | Overrides the advertised preferred prefix lifetime, in seconds (see also [[doc:uci:radvd#prefix|radvd prefix options]]) | 
| ''metric'' | integer | no | ''0'' | Specifies the default route metric to use | | ''metric'' | integer | no | ''0'' | Specifies the default route metric to use |
 +| ''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. |
 +| ''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''.  |
 +| ''adv_valid_lifetime'' | integer | no | ''300'' | (deprecated) Overrides the advertised valid prefix lifetime, in seconds (see also [[doc:uci:radvd#prefix|radvd prefix options]]) |
 +| ''adv_preferred_lifetime'' | integer | no | ''120'' | (deprecated) Overrides the advertised preferred prefix lifetime, in seconds (see also [[doc:uci:radvd#prefix|radvd prefix options]]) |
**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''. \\ **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''. \\
-**Note:** If [[doc:uci:radvd|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.+**Note:** If [[doc:uci:radvd|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) 
 + 
 + 
 +=== Protocol "6rd" (IPv6 rapid deployment) === 
 + 
 +:!: The package ''6rd'' must be installed to use this protocol. 
 + 
 +^ Name ^ Type ^ Required ^ Default ^ Description ^ 
 +| ''peeraddr'' | IPv4 address | yes | no | 6rd - Gateway  | 
 +| ''ipaddr'' | IPv4 address | no | Current WAN IPv4 address | Local IPv4 endpoint address | 
 +| ''ip6prefix'' | IPv6 prefix (without length) | yes | no | 6rd-IPv6 Prefix | 
 +| ''ip6prefixlen'' | IPv6 prefix length | yes | no | 6rd-IPv6 Prefix length | 
 +| ''ip4prefixlen'' | IPv6 prefix length | no | 0 | IPv4 common prefix | 
 +| ''defaultroute'' | boolean | no | ''1'' | Whether to create an IPv6 default route over the tunnel | 
 +| ''ttl'' | integer | no | ''64'' | TTL used for the tunnel interface | 
 +| ''mtu'' | integer | no | ''1280'' | MTU used for the tunnel interface | 
 + 
 +**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''. 
 + 
 +**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). 
 + 
 + 
 +=== Protocol "dslite" (Dual-Stack Lite) === 
 + 
 +:!: The package ''ds-lite'' must be installed to use this protocol. 
 + 
 +^ Name ^ Type ^ Required ^ Default ^ Description ^ 
 +| ''peeraddr'' | IPv6 address | yes | no | DS-Lite AFTR address  | 
 +| ''ip6addr'' | IPv6 address | no | Current WAN IPv6 address | Local IPv6 endpoint address | 
 +| ''tunlink'' | Logical Interface | no | Current WAN interface | Tunnel base interface | 
 +| ''defaultroute'' | boolean | no | ''1'' | Whether to create an IPv6 default route over the tunnel | 
 +| ''ttl'' | integer | no | ''64'' | TTL used for the tunnel interface | 
 +| ''mtu'' | integer | no | ''1280'' | MTU used for the tunnel interface | 
 + 
 +:!: ds-lite operation requires that IPv4 NAT is disabled. You should adjust your settings in /etc/config/firewall accordingly. 
 + 
 +**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''.
Line 365: Line 392:
==== Aliases ==== ==== Aliases ====
 +| {{:meta:icons:tango:48px-outdated.svg.png?nolink}} | The "config alias" approach is //deprecated//. it used to be needed when multiple interfaces sharing the same device where not supported. [[https://forum.openwrt.org/viewtopic.php?pid=203943#p203943|JoW]] |
 +
 +===== Aliases: the old way =====
//Alias// sections can be used to define further IPv4 and IPv6 addresses for interfaces. //Alias// sections can be used to define further IPv4 and IPv6 addresses for interfaces.
They also allow combinations like DHCP on the main interface and a static IPv6 address in the alias, They also allow combinations like DHCP on the main interface and a static IPv6 address in the alias,
Line 401: Line 431:
  ip addr   ip addr
 +===== Aliases: the new way =====
 +
 +Basically create an 'interface' section per IP, but alias interfaces may NOT be of type bridge
 +
 +  * For non-bridged interfaces (physdev) the ''ifname'' is the <interface-of-network-for-same-phydev>
 +  * 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).
 +
 +A minimal alias definition for a bridged interface might be (for a scenario without vlans):
 +<code>config interface lan
 +        option 'ifname' 'eth0'
 +        option 'type' 'bridge'
 +        option 'proto' 'static'
 +        option 'ipaddr' '192.168.1.1'
 +        option 'netmask' '255.255.255.0'</code>
 +
 +<code>config interface lan2
 +      option 'ifname' 'br-lan'
 +      option 'proto' 'static'
 +      option 'ipaddr' '10.0.0.1'
 +      option 'netmask' '255.255.255.0'</code>
 +
 +or for a non-bridge interface
 +<code>config interface lan
 +        option 'ifname' 'eth0'
 +        option 'proto' 'static'
 +        option 'ipaddr' '192.168.1.1'
 +        option 'netmask' '255.255.255.0'</code>
 +
 +<code>config interface lan2
 +      option 'ifname' 'eth0'
 +      option 'proto' 'static'
 +      option 'ipaddr' '10.0.0.1'
 +      option 'netmask' '255.255.255.0'</code>
 +
 +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'')
==== IPv4 Routes ==== ==== IPv4 Routes ====
Line 427: Line 492:
| ''metric'' | number | no | ''0'' | Specifies the //route metric// to use | | ''metric'' | number | no | ''0'' | Specifies the //route metric// to use |
| ''mtu'' | number | no | //interface MTU// | Defines a specific MTU for this route | | ''mtu'' | number | no | //interface MTU// | Defines a specific MTU for this route |
 +| ''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 |
 +
==== IPv6 Routes ==== ==== IPv6 Routes ====
Line 450: Line 517:
| ''metric'' | number | no | ''0'' | Specifies the //route metric// to use | | ''metric'' | number | no | ''0'' | Specifies the //route metric// to use |
| ''mtu'' | number | no | //interface MTU// | Defines a specific MTU for this route | | ''mtu'' | number | no | //interface MTU// | Defines a specific MTU for this route |
 +| ''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 |
 +
 +==== IP rules ====
 +
 +Since OpenWrt Barrier Braker, 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.
 +
 +A simple IPv4 rule may look like:
 +
 +<code>config rule
 + option mark  '0xFF'
 +        option in    'lan'
 + option dest  '172.16.0.0/16'
 + option lookup '100'</code>
 +
 +  * ''0xFF'' is a [[http://www.tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.netfilter.html|fwmark]] to be matched
 +  * ''lan'' is the incoming //logical interface name//
 +  * ''172.16.0.0/16'' is the destination subnet to match
 +  * ''100'' is the routing table ID to use for the matched traffic
 +
 +Similary, an IPv6 rule looks like:
 +
 +<code>config rule6
 +        option in    'vpn'
 + option dest  'fdca:1234::/64'
 + option action 'prohibit'</code>
 +
 +  * ''vpn'' is the incoming //logical interface name//
 +  * ''fdca:1234::/64'' is the destination subnet to match
 +  * ''prohibit'' is a routing action to take
 +
 +The options below are defined for //IP rule// (''rule'' and ''rule6'') sections:
 +
 +^ Name ^ Type ^ Required ^ Default ^ Description ^
 +| ''in'' | string | no | //(none)// | Specifies the incoming //logical interface name// |
 +| ''out'' | string | no | //(none)// | Specifies the outgoing //logical interface name// |
 +| ''src'' | ip subnet | no | //(none)// | Specifies the source subnet to match (CIDR notation) |
 +| ''dest'' | ip subnet | no | //(none)// | Specifies the destination subnet to match (CIDR notation) |
 +| ''tos'' | integer | no | //(none)// | Specifies the TOS value to match in IP headers |
 +| ''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 |
 +| ''invert'' | boolean | no | ''0'' | If set to ''1'', the meaning of the match options is inverted |
 +| ''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 |
 +| ''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 |
 +| ''goto'' | rule index | ::: | ::: | The rule target is a jump to another rule specified by its ''priority'' value |
 +| ''action'' | string | ::: | ::: | The rule target is one of the routing actions outlined in the table below |
 +
 +=== Routing Actions ===
 +
 +^ Action ^ Description ^
 +| ''prohibit'' | When reaching the rule, respond with //ICMP prohibited// messages and abort route lookup |
 +| ''unreachable'' | When reaching the rule, respond with //ICMP unreachable// messages and abort route lookup |
 +| ''blackhole'' | When reaching the rule, drop packet and abort route lookup |
 +| ''throw'' | Stop lookup in the current routing table even if a default route exists |
===== Examples ===== ===== Examples =====
Line 521: Line 641:
        option 'output'    'ACCEPT'         option 'output'    'ACCEPT'
        option 'masq'      '1'</code>         option 'masq'      '1'</code>
 +
 +==== PPPoA ADSL internet connection ====
 +
 +<code>config adsl-device 'adsl'
 +        option fwannex 'a'
 +        option annex 'a'
 +
 +config interface 'wan'
 +        option proto 'pppoa'
 +        option username 'jbloggs@plusdsl.net'
 +        option password 'XXXXXXXXX'
 +        option vpi '0'
 +        option vci '38'
 +        option encaps 'vc'</code>
 +
==== Static IPv6-in-IPv4 tunnel ==== ==== Static IPv6-in-IPv4 tunnel ====
Line 647: Line 782:
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. 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.
-<code>WANIF=$(uci -P/var/state get network.wan.ifname) +<code bash> 
-iptables -I INPUT -i $WANIF -p tcp --dport 22 -j ACCEPT</code>+WANIF=$(uci -P/var/state get network.wan.ifname) 
 +iptables -I INPUT -i $WANIF -p tcp --dport 22 -j ACCEPT 
 +</code> 
 + 
 +The uci state vars are deprecated and not used anymore for network related information [[https://forum.openwrt.org/viewtopic.php?pid=203787#p203787|Quoting jow in the forum]].\\ 
 +Use /lib/functions/network.sh: 
 + 
 +<code bash> 
 +source /lib/functions/network.sh 
 + 
 +if network_get_ipaddr addr "wan"; then 
 +    echo "IP is $addr" 
 +fi 
 +</code>

Back to top

doc/uci/network.1358258487.txt.bz2 · Last modified: 2013/01/15 15:01 by steven