Im using 4G airtel dongle to connect internet on Raspberry pi , Im able to auto connect successfully to the internet when the Pi is booted.

My issue is as follows:

I have removed the dongle from the USB of Pi and when I plug it back again it doesn't connect to internet,but the Pi recognizes as modem (wwan0). Im using wvdial to connect internet.

Can anyone please help with the solution why the pi is unable to connect to internet when it is replugged ?

  • Try restarting network manager: sudo service network-manager restart Feb 15, 2017 at 22:12
  • Yes, it can be done, but my case is I want to automate it must automatically connect to internet connection when it is re-plugged.
    – rsk kumar
    Feb 17, 2017 at 2:15
  • You can write /etc/udev/rules.d/50-myUSB.rules file and make it run certain command everytime the device (certain ID_Vendor and ID_Product) is pluged in. Can you just try if you need the "sudo" part of the command in your OS on RPi... Feb 17, 2017 at 9:19

1 Answer 1


You can make a rules file in /etc/udev/rules.d/ folder and make it run a bash script when your USB device is connected. For this you need to find the ID_Vendor and ID_Product code of device. Run lsusb command. There you will see something like Bus 003 Device 005: ID ffff:0005. In this case idVendor = ffff and idProduct = 0005. Yours will be different.

Than create for example 50-myUSB.rules file in the above directory with content something like (change ID_vendor and ID_product):

ATTRS{idVendor}=="ffff", ATTRS{idProduct}=="0005", RUN+="/path/to/script.sh"

This will run script.sh every time you will plug in the device. Now you have to create the script.sh with content something like:

#! /bin/bash service network-manager restart

(Somebody can propose better script.) Now you have to give it execution permitions:

chmod +x script.sh

I am not sure if you need to restart the OS or not for the changes to take effect.

Click here if you want to know more about udev rules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.