3

Periodically my wifi connection stops working, e.g. pinging the station drops all packets, but the interface still has it's ip address, routes are ok, etc. This is very easy to fix with a mouse: I click the network connections button on lower right which shows the wired and wireless connections I have configured. I click disconnect on the wireless connection and after a few seconds I click connect, after which my wifi starts working again. How can I automate this? I can detect the failure with ping -c 1 192.168... returning 1 but I don't know how to automatically disconnect and re-establish the connection. I tried nmcli connection down id connectionname followed by nmcli connection up id connectionname but that asks for wifi password while using a mouse I don't have to enter the password again. Is there another program I could use or different nmcli subcommand I could try? I would prefer not to save the password in plaintext in a script.

2

First off, I'd look for a reason why the Wifi disconnects at all. Maybe there is some kind of automatic inactivity disconnect in your modem software? And maybe, if there is no way to disable it, you could run a ping continuously, with a long interval. Does that maintain the connection open?

If that fails, you could add the nmcli program to the sudo allowed program (maybe it already is - try sudo nmcli. You can even tell sudo not to ask for a password in that case. I don't use Fedora, so I can't really help you with the exact commands - I seem to have seen a GUI for managing sudo on a Fedora machine.

  • I should've clarified that nmcli asks for the wifi password. There's also constant traffic over wifi so timing out isn't the problem. I think the disconnect correlates with large amounts of traffic/connections but it happens about once a day so I haven't investigated further. – user1226313 Jun 5 '17 at 8:39
0

Copy the following command to your root terminal (eg:from a removable device then delete it) :

killall wpa_supplicant
wpa_supplicant -B -i <interface> -c <(wpa_passphrase YOUR-SSID YOUR-PASSPHRASE)
dhclient <interface>
ping -w 2  8.8.8.8
echo "done"

You don't need to validate with Enter , you will be connected after the dhclient command is executed . Also with the wpa_supplicant format , the SSID and the PASSWORD will not be saved on your system.

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.