Transclusion: IOT-GATE-iMX8: WiFi

From Compulab Mediawiki
Jump to: navigation, search

IOT-GATE-iMX8 / SBC-IOT-iMX8 features an optional 802.11ac WiFi interface, implemented with the Intel WiFi 6 AX200 module.

Simple Scanning

  • Sample WiFi scanning:
root@iot-gate-imx8:~# nmcli dev wifi list

The output will show the list of Access Points and Ad-Hoc cells in range. For more information about tuning WiFi interfaces refer to the “wireless-tools” man pages.

Connecting to an Access Point

The NetworkManager can be used to connect to an access point.
Access point connection command example.

Replace SSID with the wireless network name.
Replace PASSWORD with the wireless network password.
Replace Connection-Name with the new connection name.
root@iot-gate-imx8:~# nmcli radio wifi on
root@iot-gate-imx8:~# nmcli dev wifi con "SSID" password "PASSWORD" name "Connection-Name"

Creating an Access Point

The hostapd can be used to create an access point.

Access point creation example

Access point network mask 50.150.250.0/24 is used.
Replace the mask with the desired network mask.

  • Install the required utilities
root@iot-gate-imx8:~# apt-get update
root@iot-gate-imx8:~# DEBIAN_FRONTEND=noninteractive apt-get install --yes hostapd iptables-persistent
  • Create the configuration file.
Replace SSID with the wireless network name.
Replace PASSWORD with the wireless network password.
root@iot-gate-imx8:~# cat > /etc/hostapd/hostapd.conf << EOF
interface=wlan0
ssid=SSID
wpa_key_mgmt=WPA-PSK
wpa_passphrase=PASSWORD
driver=nl80211
hw_mode=g
channel=7
wpa=1
auth_algs=1
wpa_pairwise=CCMP
EOF
  • Update the network interfaces configuration to force the WiFi interface to only run in the access point mode.
root@iot-gate-imx8:~# cat >> /etc/network/interfaces << EOF

auto lo
iface lo inet loopback

auto wlan0
iface wlan0 inet static
hostapd /etc/hostapd/hostapd.conf
address 50.150.250.1
netmask 255.255.255.0
EOF
  • Update the dnsmasq configuration file for DNS relay and DHCP server on our WiFi interface.
root@iot-gate-imx8:~# cat > /etc/NetworkManager/dnsmasq.d/dnsmasq.conf << EOF
interface=lo,wlan0
no-dhcp-interface=lo
dhcp-range=50.150.250.2,50.150.250.254,255.255.255.0,12h
EOF
  • Use iptables for NAT configuration
root@iot-gate-imx8:~# iptables -t nat -I POSTROUTING 1 -s 50.150.250.0/24 ! -d 50.150.250.0/24  -j MASQUERADE
root@iot-gate-imx8:~# iptables -I FORWARD 1 -s 50.150.250.0/24 -j ACCEPT
root@iot-gate-imx8:~# iptables -I FORWARD 1 -d 50.150.250.0/24 -j ACCEPT
root@iot-gate-imx8:~# iptables-save > /etc/iptables/rules.v4
  • Prevent Network Manager from interfering with hostapd.
root@iot-gate-imx8:~# sed -i "/^plugins=/c\plugins=ifupdown,keyfile,ofono" /etc/NetworkManager/NetworkManager.conf
  • Restart the system.
root@iot-gate-imx8:~# reboot