Difference between revisions of "Transclusion: IOT-GATE-iMX8: WiFi"

From Compulab Mediawiki
Jump to: navigation, search
imported>Uri.mashiach
(Created page with "IOT-GATE-iMX8 / SBC-IOT-iMX8 features an optional 802.11ac WiFi interface, implemented with the Intel WiFi 6 AX200 module. == Simple Scanning == * Activate the interface: <p...")
 
imported>Uri.mashiach
(Access point creation example)
 
(3 intermediate revisions by 2 users not shown)
Line 2: Line 2:
  
 
== Simple Scanning ==
 
== Simple Scanning ==
* Activate the interface:
 
<pre>
 
root@iot-gate-imx8:~# ifconfig wlan0 up
 
</pre>
 
 
* Sample WiFi scanning:
 
* Sample WiFi scanning:
 
<pre>
 
<pre>
root@iot-gate-imx8:~# iwlist wlan0 scan
+
root@iot-gate-imx8:~# nmcli dev wifi list
 
</pre>
 
</pre>
 
The output will show the list of Access Points and Ad-Hoc cells in range.
 
The output will show the list of Access Points and Ad-Hoc cells in range.
Line 14: Line 10:
  
 
== Connecting to an Access Point ==
 
== Connecting to an Access Point ==
The [https://manpages.debian.org/stretch/network-manager/nmcli.1.en.html NetworkManager] can be used to connect to an access point.
+
The [https://manpages.debian.org/stretch/network-manager/nmcli.1.en.html NetworkManager] can be used to connect to an access point.<br>
In the following example:
+
Access point connection command example.
* Replace SSID with the wireless network name.
+
:Replace SSID with the wireless network name.
* Replace PASSWORD with the wireless network name.
+
:Replace PASSWORD with the wireless network password.
* Replace Connection-Name with the new connection name.
+
:Replace Connection-Name with the new connection name.
 
<pre>
 
<pre>
 
root@iot-gate-imx8:~# nmcli radio wifi on
 
root@iot-gate-imx8:~# nmcli radio wifi on
root@iot-gate-imx8:~# nmcli dev wifi con "SSID" "PASSWORD" name "Connection-Name"
+
root@iot-gate-imx8:~# nmcli dev wifi con "SSID" password "PASSWORD" name "Connection-Name"
 +
</pre>
 +
 
 +
== Creating an Access Point ==
 +
The [https://manpages.debian.org/testing/hostapd/hostapd.8.en.html hostapd] can be used to create an access point.
 +
===Access point creation example===
 +
Access point network mask 50.150.250.0/24 is used.<br>
 +
Replace the mask with the desired network mask.
 +
* Install the required utilities
 +
<pre>
 +
root@iot-gate-imx8:~# apt-get update
 +
root@iot-gate-imx8:~# DEBIAN_FRONTEND=noninteractive apt-get install --yes hostapd iptables-persistent
 +
</pre>
 +
* Create the configuration file.
 +
:Replace SSID with the wireless network name.
 +
:Replace PASSWORD with the wireless network password.
 +
<pre>
 +
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
 +
</pre>
 +
* Update the network interfaces configuration to force the WiFi interface to only run in the access point mode.
 +
<pre>
 +
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
 +
</pre>
 +
* Update the dnsmasq configuration file for DNS relay and DHCP server on our WiFi interface.
 +
<pre>
 +
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
 +
</pre>
 +
* Use iptables for NAT configuration
 +
<pre>
 +
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
 +
</pre>
 +
* Prevent Network Manager from interfering with hostapd.
 +
<pre>
 +
root@iot-gate-imx8:~# sed -i "/^plugins=/c\plugins=ifupdown,keyfile,ofono" /etc/NetworkManager/NetworkManager.conf
 +
</pre>
 +
* Restart the system.
 +
<pre>
 +
root@iot-gate-imx8:~# reboot
 
</pre>
 
</pre>

Latest revision as of 07:47, 1 February 2021

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