Changes between Initial Version and Version 1 of OpenWrt/network_config


Ignore:
Timestamp:
10/22/2017 05:28:45 AM (7 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • OpenWrt/network_config

    v1 v1  
     1[[PageOutline]]
     2
     3= OpenWrt Network Configuration =
     4OpenWrt completely replaces the conventional Linux distribution methods of network configuration. The various config files are replaced with the Unified Configuration Interface or [http://wiki.openwrt.org/doc/uci UCI].
     5
     6OpenWrt manages its own 'virtual' network interface names in /etc/config/network.
     7
     8See Also:
     9 * [http://wiki.openwrt.org/doc/uci/wireless OpenWrt Wiki for Wireless]
     10 * [http://wiki.openwrt.org/doc/uci OpenWrt UCI]
     11 * [wiki:OpenWrt/wireless OpenWrt Wireless]
     12
     13== UCI and config files ==
     14You can use the {{{uci}}} command-line utility to get/set configuration or edit the files directly under /system/config (if you know what your doing). Often we will provide uci command-line examples because these can be easily cut-n-pasted into a shell.
     15
     16UCI configuration can be edited in the files in /etc/config directly or by using {{{uci}}} commands. Often we will provide uci command-line examples because these can be easily cut-n-pasted into a shell.
     17
     18Network configuration is contained in /etc/config/network.
     19
     20Example configuration for a single ENET interface:
     21 * looking at /etc/config/network
     22{{{
     23root@OpenWrt:/# cat /etc/config/network
     24config interface 'loopback'
     25        option ifname 'lo'
     26        option proto 'static'
     27        option ipaddr '127.0.0.1'
     28        option netmask '255.0.0.0'
     29
     30config interface 'lan'
     31        option ifname 'eth0'
     32        option type 'bridge'
     33        option proto 'static'
     34        option ipaddr '192.168.1.1'
     35        option netmask '255.255.255.0'
     36        option ip6assign '60'
     37
     38config interface 'wan6'
     39        option ifname '@wan'
     40        option proto 'dhcpv6'
     41
     42config globals 'globals'
     43        option ula_prefix 'fda7:b97b:37b2::/48'
     44
     45}}}
     46 * using UCI:
     47{{{
     48root@OpenWrt:/# uci show network
     49network.loopback=interface
     50network.loopback.ifname=lo
     51network.loopback.proto=static
     52network.loopback.ipaddr=127.0.0.1
     53network.loopback.netmask=255.0.0.0
     54network.lan=interface
     55network.lan.ifname=eth0
     56network.lan.type=bridge
     57network.lan.proto=static
     58network.lan.ipaddr=192.168.1.1
     59network.lan.netmask=255.255.255.0
     60network.lan.ip6assign=60
     61network.wan6=interface
     62network.wan6.ifname=@wan
     63network.wan6.proto=dhcpv6
     64network.globals=globals
     65network.globals.ula_prefix=fda7:b97b:37b2::/48
     66}}}
     67
     68
     69To change the IP address of the '''lan''' network which is configured as a bridge containing the '''eth0''' interface using UCI:
     70{{{
     71uci set network.lan.ipaddr 192.168.1.2
     72uci commit
     73}}}
     74
     75You can restart the networking by typing the following command:
     76{{{
     77/etc/init.d/network restart
     78}}}
     79
     80
     81[=#stp]
     82== Spanning Tree Protocol - STP ==
     83The Spanning Tree Protocol (STP) is a network protocol that builds a logical loop-free topology for Ethernet networks. The basic function of STP is to prevent bridge loops and the broadcast radiation that results from them.
     84
     85By default bridges are configured without STP thus if you connected multiple ports in a bridge to a LAN you would create a bridge loop.
     86
     87You can enable STP to avoid bridge loops if you do want to connect multiple ports in a bridge to a LAN for redundancy purposes. To do so, edit {{{/etc/config/network}}} and add an {{{option stp 1}}} to the interface.
     88
     89For example:
     90{{{
     91config interface 'lan'
     92        option ifname 'eth0'
     93        option force_link '1'
     94        option type 'bridge'
     95        option proto 'static'
     96        option ipaddr '192.168.1.1'
     97        option netmask '255.255.255.0'
     98        option ip6assign '60'
     99        option stp      1
     100
     101}}}
     102
     103Verify with the brctl show command:
     104{{{
     105root@OpenWrt:/# brctl show
     106bridge name     bridge id               STP enabled     interfaces
     107br-lan          7fff.00d0127af035       yes             eth0
     108}}}