Search by Tags

Toradex’s Linux Images - How to setup the Wi-Fi interface for Access Point Mode

Applicable for


Article updated at 18 Mar 2020
Compare with Revision

Subscribe for this article updates


This article describes how to set up a Wi-Fi Access Point, sometimes mentioned as AP mode, using open-source software Hostapd in Embedded Linux.

Other Wi-Fi related articles

If this is not the information you are looking for, please, refer to the Wi-Fi Connectivity with Toradex’s Computer on Module (CoM) article for more Wi-Fi related information.


First of all, make sure that the Wi-Fi adapter supports Access Point mode. You can check a list of tested modules in the Adding Wi-Fi Connectivity to Toradex’s Computer on Module (CoM) article.

Note: Toradex Computer on Modules (COMs) with integrated Wi-Fi/Bluetooth supports Access Point mode

This setup was tested using the following hardware and software:

  • Embedded Linux BSP release 2.8
  • Colibri iMX6ULL 512MB WB IT V1.1A.

Instructions may vary when using other Wi-Fi adapters.

Configure AP Mode

Steps are provided for configuring AP mode.

Get the Correct Interface Name

Check current mode and available interfaces, you should see a single interface in AP mode, like this:

$ iw dev
        Interface <IF_NAME>
                ifindex 5
                wdev 0x2
                addr d0:c5:d3:33:cd:31
                type **AP**
                txpower 0.00 dBm

Considering the test environment from Prerequisites section, the name of the interface is uap0.

Configure Hostapd

Set the Access Point interface IP and SSID in Hostapd configuration file. Change the following variables in /etc/hostapd.conf:

interface=<IF_NAME> # Access Point interface name ssid=access-point # SSID hw_mode=g # default channel=1 # default own_ip_addr= # IP address of the Access Point interface #wpa=1 # no wpa

To provide the Access Point interface with a static IP address and DHCP, it is necessary to create the file /etc/systemd/network/

[Match] Name=<IF_NAME> [Network] Address= DHCPServer=yes

The Hostapd service starts concurrently with the network manager and it fails. To work around this, edit the property After from file /lib/systemd/system/hostapd.service:


Reload the systemd configuration:

systemctl --system daemon-reload

Enble Hostapd

At last, activate the following services:

$ connmanctl enable wifi
$ systemctl enable hostapd
$ systemctl start hostapd

Check the Access Point interface:

$ ip a s dev <IF_NAME>

Now you can connect to this Access Point from other Wi-Fi devices. Access Point will automatically start after reboot.

Configure Internet Sharing

Once AP Mode is configured, it's a common scenario to share an internet connection from another interface. This section relies on the Internet Sharing article from the Arch Wiki.

Enable Packet Forwarding

Create a file to add the packet forwarding rules:


The changes will take effect after a reboot.

Enable NAT

NAT relies on kernel configuration and userspace tools. This section is thus split into two.

Kernel Configuration

For the example from this article, we have to make sure that the following kernel parameters are enabled. You have to evaluate if additional parameters are required for your use case:


You will find those configs in Networking support > Networking options > Network packet filtering framework (Netfilter). See an illustration (you may click it to see in higher resolution):

  • Core Netfilter Configuration

    Core Netfilter Configuration Menu

It may be possible to compile those configs as modules - check the kernel documentation. For instructions on how to build the kernel or modules, read the article Build U-Boot and Linux Kernel from Source Code.

After the new kernel is deployed, you can verify if it has the correct configs:

zcat /proc/config.gz | grep IP_NF_IPTABLES
zcat /proc/config.gz | grep NETFILTER_XT_MATCH_CONNTRACK

iptables Configuration and Setup

You might have to enable some kernel modules, depending on your configuration.

You can use iptables to enable NAT and a systemd service to make it start on reboot. First, enable the rules for the current session:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i uap0 -o eth0 -j ACCEPT

Save the current config to /etc/iptables/iptables.rules:

mkdir /etc/iptables/
iptables-save > /etc/iptables/iptables.rules

Create a systemd service file iptables.service. The example is modified from the iptables package from Arch Linux:

Description=IPv4 Packet Filtering Framework
ExecStart=/usr/sbin/iptables-restore /etc/iptables/iptables.rules
ExecReload=/usr/sbin/iptables-restore /etc/iptables/iptables.rules

Notice that in the example above we don't have the rule to stop the service. Carefully evaluate if you need it and the best method for stopping the service, where a good starting point is the iptables package aforementioned.

Reload the systemd services and enable:

systemctl --system daemon-reload
systemctl enable iptables

Enable DHCP and DNS

Some utils can enable both DHCP and DNS servers. You might want to use dhcpd or dnsmasq.