Use the command line to set the Raspberry Pi wifi network and the command line Raspberry Pi wifi

Source: Internet
Author: User

Use the command line to set the Raspberry Pi wifi network and the command line Raspberry Pi wifi

If you have not logged on to the Common graphic user interface, This method is suitable for setting Raspberry Pi's wifi. Especially when you do not have a screen or wired network, you only use the serial control line. In addition, this method does not require additional software, and everything is included in Raspberry Pi.


Getting wifi network details (get wifi network details)


You can useSudo iwlist wlan0 scanCommand. This command lists all available Wi-Fi networks and some useful information about the network. For example:


1,ESSID: "testing": This is the name of the Wi-Fi network.

2,IE: IEEE 802.11i/WPA2 Version1: This part indicates the network authentication method. Here it is WPA2, which is a safer wireless network standard to replace wpa1. This Guide applies to WEP, WPA, or WPA2, but may not to WPA2 Enterprise Edition.


You also need a wi-fi password. Most home routers (default passwords) are labeled on the labels on the back of the vro. In this example, the ESSID (ssid) of the searched Wi-Fi network is testing, and the password (psk) is testingPassword.


Adding the network details to the rassberry pi (add the network to Raspberry PI)


Open with nano EditorWpa-supplicanT configuration file:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf


Add the following content at the bottom of the file:

network={    ssid="The_ESSID_from_earlier"    psk="Your_wifi_password"}


In this example, we should add:

network={    ssid="testing"    psk="testingPassword"}


Now pressCtrl + xKey and then pressYKey, and then pressEnter key.


At this time,Wpa-supplicantIn a few seconds, you should notice that the settings have changed and will try to connect to the network. If not, useSudo ifdown wlan0

AndSudo ifup wlan0Command to manually restart the interface, or directly useSudo rebootCommand to restart Raspberry Pi.


You can useIfconfig wlan0Command to check whether the network is successfully connected. IfInet addrIt indicates that Raspberry Pi is successfully connected to the network. If not, check whether your password and ESSID are correct.



Address: http://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md



Can Raspberry Pi be connected to wifi?

Connect to the wireless network card. USB. Small. It is best to buy a match with it. Low Power Consumption.

Restart the operating system. Then, you can use the wifi-config on the desktop.

The cmd command is used to start Wi-Fi.

Step 1: Enter the command: netsh wlan set hostednetwork mode = allow

Step 2: Enter netsh wlan set hostednetwork ssid = the name of your desired wireless network key = the password you want to set in the command prompt
(Note that there is a space between the name of the wireless network you want and the key = password.) In this step, set the wireless network name and password. The password must be 8 characters in length.

Step 3. Open the network sharing center in the lower right corner of the desktop-> change the Adapter settings. You will find that there is an additional Microsoft Virtual wlan Miniport Adapter, which is the wireless network Adapter we just virtualized.

Step 4: Open the network sharing center-> change the adapter settings, right-click your local connection, that is, the wired network card that you connect to the network, (I use China Mobile Wireless 3G Internet access, therefore, the local connection is selected in this step. Please select according to your actual situation) Select properties, click share, and select "allow other network users to connect to and connect over the Internet, select the created virtual network from the drop-down list and click OK.

Step 5: Enter netsh wlan start hostednetwork in the command prompt (this step is to open the virtual wireless network, in this way, your Wi-Fi phone can be linked to the virtual Wifi network you just created)
In this way, a Wifi hotspot is created on the laptop of your win7 system, and your Wi-Fi phone can be connected to this virtual Wi-Fi network as if your laptop was connected to a wireless route.

Finally, note:

1. I found someone using their own Windows 7 laptop to build a Wi-Fi hotspot that can be connected but cannot access the Internet. I also encountered this problem, but it was very strange later.

2. After this is set up. It does not run automatically at startup. Therefore, if you want to use it at startup, you must manually enter the netsh wlan start hostednetwork command in the cmd command line to enable your Wi-Fi network.

3. the command prompt may be started by the Administrator, and the NIC must support Wireless AP mode.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.