[Raspberry Pi] USB wireless network card automatically connected

Source: Internet
Author: User

[Raspberry Pi] USB wireless network card automatically connected

When the Raspberry Pi uses a USB wireless network card, it will not be dropped because the route is restarted.

#! /Bin/bash
While true; do
If ifconfig wlan0 | grep-q "inet addr:"; then
Sleep 60
Else
Echo "Network connection down! Attempting reconnection ."
Ifup -- force wlan0
Sleep 10
Fi
Done
------ Evil split line -----
#! /Bin/bash
If ifconfig wlan0 | grep-q "inet addr:"; then
Exit
Else
Echo "Network connection down! Attempting reconnection ."
Ifup -- force wlan0
Fi
# Crontab-e
#*/10 * bash/home/network-monitor.sh # Run Once every 10 minutes

Copy the code to your root directory and save it as a network-monitor.sh and then run the command.

Sudo chmod + x./network-monitor.sh

Set it to an executable file and run the command in the background.

Sudo./network-monitor.sh &

It checks every 60 seconds if your wireless network has a network connection. If it finds that it does not have a network address, it will try to force a new connection and continue this operation until the connection is established again. If you want to prevent it from running in the background, first use the following command.
Fg
It will force it to run for the foreground, and then you can use ctrl-c to stop.
It has been tested in several aspects.
First, close my WiFi access point. This script does not detect network connections and begins to try to force a connection. After several minutes, connect the power supply access point again.
In another experiment, I deleted the MAC address from the address list and allowed the MAC address filtering of the Access Point. After the network is connected, the re-enabled MAC address and it will return in one or two minutes.

How to run Ubuntu Snappy Core in Raspberry Pi 2

Install NodeJS on the (Raspberry Pi) Raspberry Pi

Install Weston on Raspberry Pi

Linux OS for Raspberry Pi is available

Raspberry Pi (Raspberry Pi) trial note

Introduction to Raspberry Pi (Raspberry Pi) installation, IP configuration, and software source

This article permanently updates the link address:

Related Article

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.