Running Ubuntu 16.04 the WiFi-only computer has a marginal connection to the router. Usually it works for hours on end and even has worked for days.

It is using a rt2800usb external USB WiFi adapter (it claims 3000mW) with a 14 inch antenna on it. (Perhaps I need a yagi or a dish?)

I never use suspend; just lock. This is a computer located out in a workshop but I do use RDP to access it for various tasks (like monitoring the workshop and CPU temperature environment with an Arduino connected via USB).

To the problem at hand: Occasionally the connection drops. I'm not sure why but it will drop the connection entirely from time to time.

To fix it requires logging in out there and using the up/down icon to shut off Wireless then turn it back on. Then it will again go for hours or days working fine.

It would be preferable if it could reconnect itself when this happens.

The only other questions I see here on this subject are like 5 years old and for previous versions, or involving suspend. None match the conditions of this box.

So, the question is in the title. How can I set up 16.04 to automatically reconnnect when it drops off?

  • Upvote for the answer about the network manager dispatcher. I looked all through the man file and think I kinda get it. But right off the bat, Ubuntu 16.04 LTS will not allow me to create any new files in /etc/NetworkManager/dispatcher.d even with sudo. So the first answer is incomplete. Perhaps there is someone else who can weigh in on this?
    – SDsolar
    Jul 22 '17 at 4:38

You can use Network-Manager dispatcher scripts to achieve such behavior. You can find more info about those in the Ubuntu manpages. In short: you put a script, which is owned by root and executable, in the folder: /etc/NetworkManager/dispatcher.d.

If you plan on putting more such scripts in there, be aware, that they get executed in alphabetical order.

A script that starts a connection, if the same connection went down could look like this:


if [ "$CONNECTION_UUID" = "put_your_uuid_here" ]; then
    if [ "$2" = "down" ]; then
        sleep 10
        nmcli con up uuid $CONNECTION_UUID

Be aware, that you need to put the uuid of your connection in the script where it says put_your_uuid_here. To find your connections uuid you can run the command nmcli con show in a terminal.


  • 1
    Apparently you have figured it out by now. Anyway, just for completeness, an easy way to work as root in the mentioned directory is to call sudo su in the terminal. This way you won't have to call sudo all the time. Of course you should quit this root terminal when you are done by calling exit and THINK before you issue a command as bad things could happen...
    – romed
    Jul 24 '17 at 7:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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