Wifi NetworkManager: Difference between revisions

From Variscite Wiki
No edit summary
No edit summary
Line 1: Line 1:
{{PageHeader|Wireless}}  
<!-- Set release according to "release" parameter in URL and use RELEASE_SUMO_V1.0_DART-MX8M as default
--> {{#vardefine:RELEASE_PARAM|{{#urlget:release}}}} <!--
--> {{#lst:Yocto_Platform_Customization|{{#var:RELEASE_PARAM|RELEASE_SUMO_V1.0_DART-MX8M}}}} <!--
--> {{PageHeader|Wireless}}  
{{DocImage|category1=Yocto|category2=DART-MX8M}}[[Category:DART-MX8M-MINI]] __toc__
{{DocImage|category1=Yocto|category2=DART-MX8M}}[[Category:DART-MX8M-MINI]] __toc__


Line 83: Line 86:
  Run TCP test for 30 seconds
  Run TCP test for 30 seconds
  # iperf3 -c <IP_ADDRESS_OF_IPERF_SERVER> -t 30
  # iperf3 -c <IP_ADDRESS_OF_IPERF_SERVER> -t 30
= Access Point =
Following example will demonstrate you how to use the {#var:HARDWARE_NAME} as an access point. It will forward packets from wlan0 to eth0.
Setting up DHCP server DHCPD
DHCPD:
<pre>$ vi /etc/udhcpd.conf
# Sample udhcpd configuration file (/etc/udhcpd.conf)
# The start and end of the IP lease block
start          192.168.5.20    #default: 192.168.0.20
end            192.168.5.25    #default: 192.168.0.254
# The interface that udhcpd will use
interface  wlan0              #default: eth0
#Example
opt    dns    8.8.8.8  8.8.4.4 # public google dns servers
option  subnet  255.255.255.0
opt    router  192.168.5.1
option  lease  864000          # 10 days of seconds
</pre>
This is a network example. You need to set the IP address based on your network.
<br>Make sure WiFi is turned on and Ethernet is connected as per previous steps above before proceeding.
<br>First ensure that wpa_supplicant is not holding the device
<pre>$ killall wpa_supplicant
</pre>
Enable IP Forwarding:
<pre>$ echo 1 > /proc/sys/net/ipv4/ip_forward
$ ifconfig wlan0 192.168.5.1
$ hostapd -B /etc/hostapd.conf -P /var/run/hostapd.pid
$ udhcpd /etc/udhcpd.conf
$ iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
</pre>
Using your phone or other device connect to the access point named "test" created using the steps above. <br>
You should be able to connect and access the internet if your Ethernet has access. <br>
As a next step one should take a look at /etc/hostapd.conf. You may want to configure password access point name etc. <br>
* For more details refer to: https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf <br>

Revision as of 19:50, 28 February 2019

Wireless

Managing WiFi using NetworkManager

Enabling and disabling WiFi

To check if WiFi is enabled by NetworkManager run

# nmcli dev show wlan0

and check the GENERAL.STATE line. If WiFi is enabled, the state is either connected or disconnected. If WiFi is disabled the state is unavailable.

To enable WiFi run

# nmcli radio wifi on

or if you need to disable it you can run

# nmcli radio wifi off

Scanning for available WiFi APs

If WiFi is enabled you can get the list of available APs by running

# nmcli dev wifi list

Connecting to an open WiFi network

To connect to an open WiFi network run

# nmcli dev wifi connect <SSID>

To connect to an open hidden WiFi network run

# nmcli dev wifi connect <SSID> hidden yes

To check connection status run

# nmcli dev show wlan0

Connecting to a protected WiFi network

To connect to a protected WiFi network run

# nmcli dev wifi connect <SSID> password <password>

To connect to a protected hidden WiFi network run

# nmcli dev wifi connect <SSID> password <password> hidden yes

To check connection status run

# nmcli dev show wlan0

Managing existing connections

Once established, the connection is preserved across reboots unless deleted explicitly.

To show existing connections run

# nmcli con show

To disconnect from WiFi network run

# nmcli con down <SSID>

To reconnect to WiFi network run

# nmcli con up <SSID>

To permanently delete connection run

# nmcli con delete <SSID>

Testing WiFi throughput

Establish connection to WiFi network and use iperf3 tool on target and another host:

iperf3 server (on Target/Host):

# iperf3 -s

iperf3 client (on Host/Target):

Run UDP test for 30 seconds
# iperf3 -c <IP_ADDRESS_OF_IPERF_SERVER> -t 30 -u -b 0
Run TCP test for 30 seconds
# iperf3 -c <IP_ADDRESS_OF_IPERF_SERVER> -t 30

Access Point

Following example will demonstrate you how to use the {#var:HARDWARE_NAME} as an access point. It will forward packets from wlan0 to eth0. Setting up DHCP server DHCPD DHCPD:

$ vi /etc/udhcpd.conf 
# Sample udhcpd configuration file (/etc/udhcpd.conf)
# The start and end of the IP lease block
start           192.168.5.20    #default: 192.168.0.20
end             192.168.5.25    #default: 192.168.0.254
# The interface that udhcpd will use
interface   wlan0               #default: eth0
#Example
opt     dns     8.8.8.8  8.8.4.4 # public google dns servers
option  subnet  255.255.255.0
opt     router  192.168.5.1
option  lease   864000          # 10 days of seconds

This is a network example. You need to set the IP address based on your network.
Make sure WiFi is turned on and Ethernet is connected as per previous steps above before proceeding.
First ensure that wpa_supplicant is not holding the device

$ killall wpa_supplicant

Enable IP Forwarding:

$ echo 1 > /proc/sys/net/ipv4/ip_forward
$ ifconfig wlan0 192.168.5.1
$ hostapd -B /etc/hostapd.conf -P /var/run/hostapd.pid
$ udhcpd /etc/udhcpd.conf
$ iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Using your phone or other device connect to the access point named "test" created using the steps above.
You should be able to connect and access the internet if your Ethernet has access.
As a next step one should take a look at /etc/hostapd.conf. You may want to configure password access point name etc.