Wi-Fi Access Point

If you are using Coexistence mode 3 (Station + Access Point), they must both be at the same channel.  To determine the channel used by the Wi-Fi Station, do the following (from the Wi-Fi Station page):

mtcdt: iw dev wifi0  link

Connected to 9c:4e:20:c8:ee:9e (on wifi0)
SSID: Mtech_guest
freq: 5785

The frequency can be used to determine the channel. This channel corresponds to channel 157. This must be used in the Wi-Fi Access Point configuration file.

Configuring the cfg80211 Driver on the Device

1. Add the file to the device:


The file should contain the country code for the country where the device resides or is used:

options cfg80211 ieee80211_regdom=US

2. After doing this, cfg80211 must be reloaded. Enter the following:

mtcdt: /etc/init.d/rs9113 stop

The following results display:

rs9113: Unloading rs9113 modules
killall: wpa_supplicant: no process killed
killall: hostapd: no process killed

Then enter the following commands:

mtcdt: modprobe -r mac80211
mtcdt: modprobe -r cfg80211
mtcdt: lsmod | grep cfg80211
mtcdt: modprobe cfg80211
mtcdt: cat /sys/module/cfg80211/parameters/ieee80211_regdom

Reloading the Redpine/RS9113 Driver After a Frequency Change

If you change the frequency from 2.4GHz to 5GHz or vice versa, you must reload the rs9113 driver. It is not possible to use 2.4GHz and 5GHz simultaneously.

For Wi-Fi Station, use 2, 3 , 6 or 14 for the COEX_MODE (or coexistence parameter) in /etc/default/rs9113. Always check the COEX_MODE value before loading the driver.

To reload the driver:

1. Enter the command:

mtcdt: /etc/init.d/rs9113 restart

2.  Also, dnsmasq may already be running. The first command looks for the DNS mask. The second command kills the process(es). Include the PID of the process(es). Enter the following two commands:

mtcdt: ps -ef | grep [d]nsmasq
mtcdt: kill [pid1] [pid2]

Example kill command (one process):

mtcdt: kill 27565

 3. If you have UDHCP running. Enter:

mtcdt: ps -ef | grep [u]dhcpc
admin    27565     1  0 19:34 ?  00:00:00 udhcpc -R -n -p        /var/run/udhcpc.wifi0.pid -i wifi0

Since this is running on wifi0, it is OK. If it is running on wifi1, it should be killed.

Configuring the Hostapd File

Copy the hostapd example to a new location. This file and directory does not exist until you create it. For this example, the file is placed in:


The simplest example of the hostapd file is /opt/rs9113/hostapd_open.conf. In this case, we are using wifi1 as the device.

In the following sequence, a minus means remove, next to a line of the original /opt/rs9113/hostapd_open.conf. A plus means add, next to the replacement line in the new file (in this case, the example is /etc/network/wifi.d/hostapd.conf).

1. Find the interface line in the file and set it to wifi1:


2. Find the hw_mode and set it to the desired frequency band (g is 2.4GHz and a is 5GHz). The original file is set to g or 2.4GHz. Once this is set by the hostapd daemon, you cannot change the frequency without reloading the driver.
Here are the parameters for each mode:


3.   Set the channel number. The channel number is restricted by country or region. Here are some example parameters for setting the channel number:


The channel number must be consistent with the hardware mode. Channels 1 – 14 are 2.4GHz or hardware mode g, and channels above 14 are 5GHz or mode a.

Adding the Wi-Fi Access Point Driver Node on the Device

Add the Wi-Fi Acccess Point driver node on the device. This strarts the wifi driver on /dev/wifi1:

1. To intialize the driver and create the Virtual Access Point (VAP), enter the following command (note: the name of the driver is wifi1):

mtcdt: /opt/rs9113/onebox_util rpine0 create_vap wifi1 ap
Driver initialization is done
Creating VAP in AP mode
VAP created Successfully

2. Now activate the access point, start the daemon and give it an IP address using these commands: 

mtcdt: hostapd -B -d /etc/network/wifi.d/hostapd.conf
mtcdt: ip -4 addr flush dev wifi1
mtcdt: ip addr add dev wifi1
mtcdt: ip addr show wifi1

The following results display: 

11: wifi1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
     link/ether 00:23:a7:43:9e:e9 brd ff:ff:ff:ff:ff:ff
     inet scope global wifi1
           valid_lft forever preferred_lft forever
     inet6 fe80::223:a7ff:fe43:9ee9/64 scope link
           valid_lft forever preferred_lft forev

If hostapd produces errors, the COEX_MODE is incorrect.

Running DHCP

1. Kill off any existing DHCP or DNS server.
2. Assume dnsmasq is used for DNS and DHCP. To obtain the package file, see the following directory for dnsmasq_*.ipk: http://www.multitech.net/mlinux/feeds/3.3/arm926ejste . Install dnsmasq from the mlinux feed if not installed. Then, to add the required package, enter the following command:

mtcdt: opkg install dnsmasq_2.68-r0.0_arm926ejste.ipk

3. Stop dnsmasq using the command: 

mtcdt: /etc/init.d/dnsmasq stop

4. Place the configuration file in /etc/network/wifi.d/dnsmasq_dhcp.conf on the device. 


5. Start dnsmasq DHCP using the commands: 

mtcdt: dnsmasq --conf-file=/etc/network/wifi.d/dnsmasq_dhcp.conf --pid-    file=/var/run/dnsmasq_dhcp_wifi1.pid
mtcdt: ps -ef | grep [d]nsmasq
nobody   19856     1  0 20:53 ?        00:00:00 dnsmasq --conf-file=/home/root/dnsmasq_dhcp_wifi1.conf --pid-file=/var/run/dnsmasq_dhcp_wifi1.pid

Running DNS

To run DNS:

1. Copy this DNS file with contents below into /etc/nework/wifi.d/dnsmasq_dns.conf.


 2. Start the daemon: 

mtcdt: dnsmasq --conf-file=/etc/network/wifi.d/dnsmasq_dns.conf --pid-file=/var/run/dnsmasq_dns_wifi1.pid
mtcdt: ps -ef | grep [d]nsmasq_dns
nobody   22773     1  0 21:02 ?  00:00:00 dnsmasq --conf-file=/etc/network/wifi.d/dnsmasq_dns.conf --        pid-file=/var/run/dnsmasq_dns_wifi1.pid

Enabling Wi-Fi Routing

Before doing these steps, you must setup the Ethernet connection on the device and configure the COEX_MODE = 3 (Wi-Fi Station and Wi-Fi Access Point).

To enable Wi-Fi Routing:

1. For the access point to work (access the device from your computer), you need to lower the firewall settings to allow access. Enter the following commands:

mtcdt: iptables -P INPUT ACCEPT
mtcdt: iptables -P FORWARD ACCEPT
mtcdt: iptables -P OUTPUT ACCEPT
mtcdt: iptables -t nat –F
mtcdt: iptables -t mangle –F
mtcdt: iptables –F
mtcdt: iptables –X
mtcdt: iptables -L
Chain INPUT (policy ACCEPT)<
 target     prot opt source               destination
Chain FORWARD (policy ACCEPT)
 target     prot opt source               destination
Chain OUTPUT (policy ACCEPT)
 target     prot opt source               destination

2. Connect Wi-Fi from your GUI . Then, verify the device Wi-Fi connection to your computer. Enter this command: 

mtcdt: ip addr show wlan0

The following results should display: 

4: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether b0:7f:b9:f8:3f:b3 brd ff:ff:ff:ff:ff:ff
inet brd scope global wlan0
     valid_lft forever preferred_lft forever
inet6 fe80::b27f:b9ff:fef8:3fb3/64 scope link
     valid_lft forever preferred_lft forever

3. In order to access the internet through the device from your computer, you must enable minimal forwarding of DHCP.  NOTE: this step forwards DHCP and does not work with DHCP set up prior to this step. Do the forwarding step after the IP address is acquired via DHCP.

 a. Enable IP forwarding using this command:

mtcdt: echo 1 > /proc/sys/net/ipv4/ip_forward

b. Then change the ip tables to forward from wifi1 (the wifi access point) to wifi0 (the Wi-Fi station VAP).

mtcdt: iptables -t nat -A POSTROUTING -o wifi0 -j MASQUERADE
mtcdt: iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED
mtcdt: iptables  -A FORWARD -i wifi1 -o wifi0 -j ACCEPT
mtcdt: iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             anywhere
Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Setting Up Wi-Fi Access Point at Boot

1. First add the IP address of the station to the /etc/network/interfaces file:

auto wifi1
iface wifi1 inet static

2. Delete and copy the dnsmasq configuration files to the directory /etc/dnsmasq.d 

mtcdt: rm /etc/dnsmasq.d/*
mtcdt: cp dnsmasq_dhcp.conf dnsmasq_dns.conf /etc/dnsmasq.d

3. Now restart the interface, and restart dnsmasq using the following commands: 

mtcdt: ifup wifi1
mtcdt: ifdown wifi1
mtcdt: ifup wifi1

The resulting output displays: 

10: wifi1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:23:a7:43:4e:b1 brd ff:ff:ff:ff:ff:ff
    inet brd scope global wifi1
       valid_lft forever preferred_lft forever
    inet6 fe80::223:a7ff:fe43:4eb1/64 scope link 
       valid_lft forever preferred_lft forever
mtcdt: /etc/init.d/dnsmasq restart