# The /etc/config/lime-defaults file contains the default configuration.
# To configure LibreMesh insert options in /etc/config/lime file, these will override the default ones.
# Interface specific options have to be included in /etc/config/lime, if in /etc/config/lime-defaults they'll cause unpredictable behaviour.
#
# The options marked with "Parametrizable with %Mn, %Nn, %H"
# can include %Mn templates that will be substituted
# with the n'th byte of the primary_interface MAC
# and %Nn templates that will be replaced by the n'th (n = 1,2,3) network-identifier byte,
# calculated from the hash of the ap_ssid value, so that all the nodes that
# form a mesh cloud (share the same ap_ssid) will produce the same value
# and %H template that will be replaced by hostname
# For setting a specific WAN port, don't set it globally in section "config lime network", set it in interface specific configuration "config net ..." and install the lime-proto-wan package
# For setting the WAN port on the default WAN port (according OpenWRT), no configuration here is needed, just install the lime-hwd-openwrt-wan package.

### System options

config lime system
	option hostname 'LiMe-%M4%M5%M6'		# Parametrizable with %Mn
	option domain 'lan'				# DNS domain for the L2 cloud it could be something like mycloud.mynetwork.tld, hosts that get their IP by DHCP will also get a fully qualified domain name like hostname.mycloud.mynetwork.tld
	option keep_on_upgrade 'libremesh base-files-essential /etc/sysupgrade.conf'	# Files defining the list of files and directories to backup when upgrade. Relative to /lib/upgrade/keep.d if no '/' defined.

### Network general option

config lime network
	option primary_interface eth0			# The mac address of this device will be used in different places
	option main_ipv4_address '10.%N1.0.0/16'	# Here you have 4 possibilities: set a static IP and the subnet, like '10.0.2.1/16'; parametrize with %Mn and %Nn, and set the subnet, like '10.%N1.%M5.%M6/16'; set a whole network address (not a specific IP) for getting the IP autocompleted in that network with bits from MAC address, this works also with netmasks other than /24 or /16, like '10.0.128.0/17' (but not valid network addresses, for example '192.0.128.0/16' or '192.0.129.0/17' won't get parametrized); set two different parameters, the first for subnet and the second for IP parametrization, like '10.0.128.0/16/17', this results in /16 subnet but IP parametrized in a /17 range (from 10.0.128.1 to 10.0.255.254).
	option anygw_dhcp_start '2'			# First IP in the subnet to be used for DHCP for clients. For example, if the subnet is 10.x.0.0/16 and you want the clients to get an IPv4 from a DHCP pool starting from 10.x.100.2, the start parameter will have to be 100 * 256 + 2 = 25602.
	option anygw_dhcp_limit '0'			# Number of IPs available for DHCP. Use zero for having the DHCP pool ranging from anygw_dhcp_start up to the end of the subnet. For example, if the subnet is 10.x.0.0/16, the start of the DHCP pool is at 10.x.100.2 and you want the DHCP pool to finish at 10.x.127.254, the limit parameter will have to be (127 - 100) * 256 + (254 - 2) + 1 = 7165. Instead, if you want the DHCP pool to go from 10.x.100.2 up to 10.x.255.254 (last valid IPv4 in the /16 subnet) you can just set the limit to zero.
	option main_ipv6_address '2a00:1508:0a%N1:%N200::/64'	# Parametrizable in the same way as main_ipv4_address. If used, the IP autocompletion will fill maximum the last 24 bits, so specifying an IP autocompletion range bigger than /104 is not useful.
	option bmx6_mtu '1500'				# Set MTU for bmx6 tunnel interfaces
#	option bmx6_pref_gw 'gw_hostname'		# Force bmx6 to use a specific gateway to Internet (hostname must be used as identifier)
	list protocols ieee80211s			# List of protocols configured by LiMe, some of these require the relative package "lime-proto-...". Note that if you set here some protocols, you overwrite the *whole* list of protocols set in /etc/config/lime-defaults
	list protocols lan
	list protocols anygw
	list protocols batadv:%N1			# Parametrizable with %Nn (which depends from ap_ssid), note that this will range between 16 and 272
#	list protocols batadv:0				# If 0 VLAN tags are disabled and the routing is done on the raw interface
	list protocols bmx6:13
	list protocols olsr:14
	list protocols olsr6:15
	list protocols olsr2:16
	list resolvers 4.2.2.2 # b.resolvers.Level3.net	# DNS servers node will use
	list resolvers 141.1.1.1 # cns1.cw.net		# Set every entry empty for using the upstream (ISP) DNS server
	list resolvers 2001:470:20::2 # ordns.he.net
	option bmx6_over_batman false			# Disables Bmx6 meshing on top of batman
	option bmx6_pref_gw none
	option bmx7_over_batman false
	option anygw_mac 'aa:aa:aa:%N1:%N2:aa'		# Parametrizable with %Nn. Keep in mind that the ebtables rule will use a mask of ff:ff:ff:00:00:00 so br-lan will not forward anything coming in that matches the first 3 bytes of it's own anygw_mac (aa:aa:aa: by default)
#	option autoap_enabled 0				# Requires lime-ap-watchping installed. If enabled AP SSID is changed to ERROR when network issues
#	option autoap_hosts "8.8.8.8 141.1.1.1"		# Requires lime-ap-watchping installed. Hosts used to check if the network is working fine

### WiFi general options

config lime wifi
#	option country 'ES'
	option channel_2ghz '11'                    # May be either a list or a single option, in case of a list channel will be selected according to radio index
	option channel_5ghz '48'			# Check for allowed channels on https://en.wikipedia.org/wiki/List_of_WLAN_channels#regulatory_tables5.0ghz
#	option htmode_2ghz 'HT20'
	option htmode_5ghz 'HT40'
	option distance_2ghz '100'			# Distance between the ap and the furthest client in meters
	option distance_5ghz '1000'			# Distance between this node and the furthest connected node in meters
	list modes 'ap'
	list modes 'apname'
	list modes 'ieee80211s'
#	list modes 'adhoc'				# See below for adhoc configuration
#	list modes 'client'				# See below for client configuration
	option ap_ssid 'LibreMesh.org'
#	option ap_key 'SomeWPA2PskKey'
#	option ap_encryption 'psk2'
	option apname_ssid 'LibreMesh.org/%H'
#	option apname_key 'SomeWPA2PskKey'
#	option apname_encryption 'psk2'
	option ieee80211s_mesh_fwding '0'		# Settings needed only for 802.11s
	option ieee80211s_mesh_id 'LiMe'
#	option ieee80211s_encryption 'psk2/aes'
#	option ieee80211s_key 'SomePsk2AESKey'


# The following interface specific options have to be included in /etc/config/lime, not in /etc/config/lime-defaults

### WiFi interface specific options ( override defaults options )

## use radio0 only for mesh
config wifi radio0
	list modes 'ieee80211s'

## change ssid for radio1
config wifi radio1
	option ap_ssid 'Special'

## diable lime-config for radio2
config wifi radio2
	option modes 'manual' # If you use manual protocol you must not specify other protocol, or your configuration will be broken!


## set radio3 to adhoc with specific channel
config wifi radio3
	list modes 'adhoc'
	option channel_2ghz '1'
	option channel_5ghz '48'
	option adhoc_ssid 'LiMe' # Parametrizable with %M, %H
	option adhoc_bssid 'ca:fe:00:c0:ff:ee'
	option adhoc_mcast_rate_2ghz '24000'
	option adhoc_mcast_rate_5ghz '6000'

# If you want to use Wifi client mode just to connect to an AP offering internet
# you need two pieces of configuration the wifi specific configuration and the
# network specific one like in the following example.

## set radio4 as client of access point
option wifi radio4
	list modes 'client'
	option channel_2ghz 'auto'
	option client_ssid 'SomeWiFiNetwork'
	option client_key 'SomeWPApskPassword'
	option client_encryption 'psk' # psk for WPA or psk2 for WPA2

config net wirelessclient
	option linux_name 'wlan0-client'			# the client interface name could be named differently, like wlan1-client
	list protocols 'wan'						# use wan to get Internet connectivity via DHCP

### Network interface specific options ( override general option )
### Available protocols: bmx6, bmx7, batadv, olsr, olsr6, olsr2, bgp, wan, lan, manual, static
### proto:vlan_number works too ( something like bmx6:13 is supported )
### If you use manual do not specify other protocols, may result in an unpredictable behavior/configuration (likely you loose connection to the node)

#config net port5					# Do not put any "." in the section name
#	option linux_name 'eth1.5'			# Put here the actual name of the interface
#	list protocols 'wan'				# Some of these protocols require the relative package "lime-proto-..."
#	list protocols 'static:172.23.0.1/24'		# Set up a static IP (both IPv4 and IPv6 supported, specify twice one per IP type)


### Ground routing specific sections
### One section for each ground routing link
### With ground routing we mean setups having LibreMesh on a router which is connected via cable(s), eventually through a switch, to some wireless routers running the original firmware in WDS (transparent bridge) Ap/Sta mode.
### Likely you want to configure as many sections of ground routing with different vlan numbers or different switch ports as many connected devices in WDS mode.
### For a detailed description have a look at http://libremesh.org/projects/libremesh/wiki/Ground_routing

#config hwd_gr link1
#	option net_dev 'eth0'				# Plain ethernet device on top of which 802.1q vlan will be constructed. In case of doubts rely on wiki.openwrt.org
#	option vlan '5'					# Vlan id to use for this ground routing link, use little one because cheap switch doesn't supports big ids, this will be used also as 802.1q vid on tagged ports
#	option switch_dev 'switch0'			# These options regarding switch need to be set only if your ethernet device is connected to a switch chip. If the switch exists you can read its name (like switch0) in /etc/config/network file
#	option switch_cpu_port '0'			# Refer to switch port map of your device on wiki.openwrt.org to know CPU port index
#	list switch_ports '4t'				# List switch ports on which you want the vlan being passed, use the 't' suffix to specify the port being tagged, refer to wiki.openwrt.org for correspondence with physical ports


### Proto BGP specific sections
### One section for each BGP peer

#config bgp_peer peer1
#	option remoteIP '192.0.2.6'
#	option remoteAS '65550'

#config bgp_peer peer2
#	option remoteIP '2001:db8::c001'
#	option remoteAS '65549'