WiFi Command Line Tool
This topic provides details on using the wifi
command line tool to control the WiFi service.
The wifi
command line tool supports both client and access point options.
Also see the wifi
command line help:
# wifi help wifi command line usage ========== To run Wifi Client: wifi client help To run Wifi Access Point: wifi ap help
WiFi Client
The wifi client command line has the following options:
# wifi client help wifi command line usage ========== To start using the WiFi client: wifi client start To stop using the WiFi client: wifi client stop To start a scan: wifi client scan To create to a access point and get [REF]: wifi client create [SSID] To connect to a access point set in 'create': wifi client connect [REF] To set security protocol wifi client setsecurityproto [REF] [SecuProto] Values for SecuProto; 0: No security 1: Using WEP 2: Using WPA 3: Using WPA2 4: Using WPA Enterprise 5 :Using WPA2 Enterprise To disconnect from an access point: wifi client disconnect To delete the access point set in 'create': wifi client delete To set WPA/WPA2 passphrase that generates PSK : wifi client setpassphrase [REF] [passphrase] To set WPA/WPA2 PSK directly: wifi client setpsk [REF] [PSK] To set WPA/WPA2 Enterprise user credentials: wifi client setusercred [REF] [username] [password] To set WEP Key: wifi client setwepkey [REF] [WEPKEY]
Client Example
This example shows how a client connects to an open access point with no security
Start the wifi client
>wifi client start
Scan for available access points. Note the references in the response.
>wifi client scan starting scan Found: SSID: "GustavNet" Strength:-49 Ref:0x10000003 Found: SSID: "hotspot" Strength:-54 Ref:0x10000001 Found: SSID: "NEUF_B698" Strength:-71 Ref:0x10000009 Found: SSID: "SFR WiFi FON" Strength:-71 Ref:0x10000007 Found: SSID: "SFR WiFi Mobile" Strength:-71 Ref:0x10000005
Set security preference for accesspoint "hotspot"
> wifi client setsecurityproto 10000001 0
Connect to hotspot with reference 10000001
> wifi client connect 10000001
note that IP handling is not handled by the wifi command line tool but here is how it can be done
> /sbin/udhcpc -R -b -i wlan0 udhcpc (v1.22.1) started Sending discover... Sending select for 192.168.43.25... Lease of 192.168.43.25 obtained, lease time 3600 /etc/udhcpc.d/50default: Adding DNS 192.168.43.1
now try your IP connection towards the internet by pinging Google's DNS
> ping 8.8.8.8
WiFi access point
The wifi access point command line has the following options:
# wifi ap help WiFi command line access point usage ========== To start the WiFi access point: wifi ap start To stop the WiFi access point: wifi ap stop To set the SSID of the WiFi access point: wifi ap setssid [SSID] To set the channel of the WiFi access point: wifi ap setchannel [ChannelNo] To set the security protocol used : wifi ap setsecurityproto [SecuProto] Values for SecuProto; 0: No security 1: Using WPA2 To set WPA2 passphrase that generates PSK : wifi ap setpassphrase [passphrase] To set WPA2 PSK directly: wifi ap setpsk [PSK] To set the discoverablity of the WiFi access point: wifi ap setdiscoverable To maximum nbr of clients for the WiFi access point: wifi ap setmaxclients [MAXNBR] To define the address of the AP and the IP addresses range as well: WARNING: Only IPv4 addresses are supported. wifi ap setiprange [IP AP] [IP START] [IP STOP]
Access Point Example
This example shows how to setup a open access point WPA2 security.
set the security to none.
> wifi ap setsecurityproto 1
set the pass phrase
> wifi ap setpassphrase secret123
set the name of the access point
> wifi ap setssid EXAMPLESSID
start the AP
> wifi ap start
DHCP IP handling the wifi service does not handle the DHCP IP handling. To bridge the DHCP server and the modem the following can be done.
> /sbin/ifconfig wlan0 192.168.10.1 up // Configure the interfaces // interface of the WiFi access point (LAN - Local Area Network) > export ITF_LAN="wlan0" // interface WAN: "rmnet0" or "eth0" (WAN - Wide Area Network) > export ITF_WAN="rmnet0" //IP & mask for subnet > export SUBNET="192.168.10.0/24" > export IP="192.168.10.1" > export IP_RANGE_START="192.168.10.10" > export IP_RANGE_END="192.168.10.20" // Start rmnet0 with pin 3699 > /mnt/legato/system/bin/cm sim enterpin 3699 > /mnt/legato/system/bin/cm data connect & // bring up the interface >/sbin/ifconfig wlan0 $IP up // DNSMASQ Startup > /usr/bin/dnsmasq --interface=${ITF_LAN} --dhcp-range=$IP_RANGE_START,$IP_RANGE_END,12h -d --bogus-priv& // Turn on IP forwarding > echo 1 > /proc/sys/net/ipv4/ip_forward // load masquerade module > /proc/sys/kernel/modprobe ipt_MASQUERADE > /usr/sbin/iptables -A POSTROUTING -t nat -o ${ITF_WAN} -j MASQUERADE > /usr/sbin/iptables -A FORWARD --match state --state RELATED,ESTABLISHED --jump ACCEPT > /usr/sbin/iptables -A FORWARD -i ${ITF_LAN} --destination ${SUBNET} --match state --state NEW --jump ACCEPT > /usr/sbin/iptables -A INPUT -s ${SUBNET} --jump ACCEPT
Copyright (C) Sierra Wireless Inc.