How to connect to the Internet via wireless

From WRTnode Wiki
Jump to: navigation, search
This page is a translated version of the page 如何通过无线连上互联网 and the translation is 100% complete.

Other languages:

WRTnode connected to the Internet through wireless

Now we will connect WRTnode2P to the internet. of course, you must have a 2.4G Wi-Fi ap or router with has connected on the internet.

The new version of the firmware can be connected through the setwifi command

If your firmware kernel version is greater than 3.18.20;
View firmware version command:

root@OpenWrt:~# uname -a
root@OpenWrt:~# setwifi SSID_you_connetctin the_password
  • Scan the Wi-Fi available
root@OpenWrt:~# aps

'aps' is the command of WRTnode2P to scan the Wi-Fi available, the output of 'aps' looks like this:

WRTnode AP scaner.
Begin scaning APs, pls wait...
Finished.
APs available are...
ra0       get_site_survey:
Ch  SSID                             BSSID               Security               Siganl(%)W-Mode  ExtCH  NT WPS DPID
1   Tenda                            xx:xx:xx:xx:xx:xx   NONE                   70       11b/g/n ABOVE  In YES
1   hshn                             xx:xx:xx:xx:xx:xx   WPA2PSK/AES            96       11b/g/n NONE   In YES
6   TP-LINK                          xx:xx:xx:xx:xx:xx   NONE                   55       11b/g   NONE   In  NO
6   BY01                             xx:xx:xx:xx:xx:xx   NONE                   100      11b/g/n NONE   In YES
6   Tenda_xxxxxx                     xx:xx:xx:xx:xx:xx   WPAPSK/AES             50       11b/g/n ABOVE  In  NO
11  CU_wpFS                          xx:xx:xx:xx:xx:xx   WPAPSK/TKIPAES         70       11b/g/n NONE   In YES

ok,we will connect one:

root@OpenWrt:~# setwifi SSID_you_connetctin the_password

be careful, there's a space between the SSID and the password
Such as:

root@OpenWrt:~# setwifi TP_linkAB33CD my_password

Press Enter and wait 5 seconds, or sometimes we need to reconnect our computer to the WRTnode2P's SSID, so let's see if we have got the IP address from uppter router:

root@OpenWrt:~# ia

we'll see

 $ ia
apcli0    Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
          inet addr:192.168.1.103  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: xxxx::xxxx:xxxx:xxxx:xxxx/xx Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

sometimes getting the IP address will lasts more than 5 seconds, so be patient. Once we got the IP address, let's see if the board have access the internet:

root@OpenWrt:~# ping baidu.com
PING baidu.com (220.181.111.85): 56 data bytes
64 bytes from 220.181.111.85: seq=0 ttl=54 time=6.071 ms

See, thus we connected our computer to the WRTnode2P, and we connected the WRTnode2P to the internet.

Common methods

Scan the Wi-Fi available

$ aps

'aps' is the command of WRTnode2P to scan the Wi-Fi available, the output of 'aps' looks like this:

WRTnode AP scaner.
Begin scaning APs, pls wait...
Finished.
APs available are...
ra0       get_site_survey:
Ch  SSID                             BSSID               Security               Siganl(%)W-Mode  ExtCH  NT WPS DPID
1   Tenda                            xx:xx:xx:xx:xx:xx   NONE                   70       11b/g/n ABOVE  In YES
1   hshn                             xx:xx:xx:xx:xx:xx   WPA2PSK/AES            96       11b/g/n NONE   In YES
6   TP-LINK                          xx:xx:xx:xx:xx:xx   NONE                   55       11b/g   NONE   In  NO
6   BY01                             xx:xx:xx:xx:xx:xx   NONE                   100      11b/g/n NONE   In YES
6   Tenda_xxxxxx                     xx:xx:xx:xx:xx:xx   WPAPSK/AES             50       11b/g/n ABOVE  In  NO
11  CU_wpFS                          xx:xx:xx:xx:xx:xx   WPAPSK/TKIPAES         70       11b/g/n NONE   In YES

Modify the configuration file

Then we have to change the settings of aplci on WRTnode, aplci is configuring the up-link part of the router inside of WRTnode (that's it: WRTnode has an internal router)

$ vw

'vw' is a WRTnode customized command which changes /etc/config/wireless. It is used the file editor named 'vi', a standard editor for Linux, but not very comfortable to use it, therefore here are the tips:

 config wifi-device 'ra0'
         option type 'ralink'
         option mode '9'
         option channel '6' #This is change number 1
         option txpower '100'
         option ht '20+40'
         option country 'US'
         option disabled '0'
 
 config wifi-iface
         option device 'ra0'
         option network 'lan'
         option mode 'ap'
         option encryption 'psk2'
         option key '12345678'
         option ApCliEnable '1'
         option ApCliSsid 'aAP' #This is change number 2
         option ApCliAuthMode 'WPA2PSK' #This is change number 3
         option ApCliEncrypType 'AES' #This is change number 4
         option ApCliPassWord '87654321' #This is change number 5
         option ssid 'WRTnodeXXXX'
  • Change number 1: set the WiFi channel to match the one from our router 'OUR_WIFI' (specified on column 'Ch' from aps output)
  • Change number 2: set the WiFi SSID to match the one from our router 'OUR_WIFI'
  • Change number 3: set the ApCliAuthMode to match the one from our router 'OUR_WIFI'

Here are the accepted parameters for ApCliAuthMode / ApCliEncrypType, from vw according to aps' security:

aps:Security           vw:ApCliAuthMode/ApCliEncrypType
=========================================================
WPA1PSKWPA2PSK/TKIPAES	WPA2PSK/AES
WPA2PSK/AES		WPA2PSK/AES
WPA2PSK/TKIP		WPA2PSK/TKIP
WPAPSK/TKIPAES		WPAPSK/TKIP
WPAPSK/AES		WPAPSK/AES
WPAPSK/TKIP		WPAPSK/TKIP
WEP			WEP/WEP
NONE			NONE/NONE
  • Change number 4: set the ApCliEncrypType to match the one from our router 'OUR_WIFI'
  • Change number 5: set the Password to match the one from our router 'OUR_WIFI' (this must be known by the router owner)

Additionally, if 'OUR_ROUTER' router uses ASCII WEP password, you will need to perform the following commands into HEX code

root@OpenWrt:~# echo -n 'abcde' | hexdump -e '13/1 "%02x" "\n"'   #To convert abcde to 6162636465

Also uci (specific to OpenWRT operating system) can be used to change the above settings, but this is beyond the scope of this Wiki section.

Restart WRTnode network

$ wifi

'wifi' is a WRTnode customized command which will reset the network side. After 10 seconds it is possible to connect again to WRTnode's SSID.

View apcli0 status

$ ia

'ia' is a WRTnode customized command which is equivalent to ifconfig apcli0.

$ ia
apcli0    Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
          inet addr:192.168.1.103  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: xxxx::xxxx:xxxx:xxxx:xxxx/xx Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Sometimes, router 'OUR_WIFI' may lease the IP after tens of seconds. Let's verify if WRTnode is connected to Internet. === Modify WRTnode's gateway ===:
'vn' is a WRTnode customized command which is equivalent to vim /etc/config/network.

 
$ vn
......
config interface 'lan'
        option ifname 'eth0.1'
        option force_link '1'
        option macaddr '64:51:7e:80:17:76'
        option type 'bridge'
        option proto 'static'
        option ipaddr '192.168.8.1'   //WRTnode's gateway
        option netmask '255.255.255.0'
        option ip6assign '60'
......

Verify WRTnode is connected to the Internet

Let's verify if WRTnode is connected to Internet.

$ ping baidu.com
PING baidu.com (220.181.111.85): 56 data bytes
64 bytes from 220.181.111.85: seq=0 ttl=54 time=6.071 ms

In this moment the WRTnode board is connected to the Internet through our home router, we can connect our PC to Internet through the WRTnode and start configure our WRTnode board.