On Ubuntu 14.04, I am using a USB wireless adapter to connect to a wireless network. The connection is often disconnected (I have tried to solve the problem, but I don't know why. That is another question. See the output of
dmesg | grep wlan here).
My Network Manager sometimes can automatically reconnect, but sometimes it can't.
So when it disconnects, I often have to run
sudo dhclient -v wlan1
to reconnect. If that doesn't work, I will run
sudo wpa_supplicant -B -i wlan1 -c /etc/wpa_supplicant.conf sudo dhclient -v wlan1
If that doesn't work, I will also reload its driver
sudo modprobe -r rt2800usb sudo modprobe rt2800usb sudo wpa_supplicant -B -i wlan1 -c /etc/wpa_supplicant.conf sudo dhclient -v wlan1
How shall we automatically run the commands every time it disconnects, i.e. make re-connection automatic?
There is a problem that mostly the logic name for my USB adapter is
wlan1 but sometimes is