10456 questions

12460 answers

19384 comments

21896 members

0 votes
111 views 2 comments
by
How do I restart the wifi interface from SSH?
I can change static ip addresses by editing /etc/config/dhcp and then running /etc/init.d/dnsmasq restart
But that's not enough - until all concerned devices disconnect and reconnect to the wifi, they keep their old ip addresses.

Thanks!

1 Answer

0 votes
by

Hello,

When changing anything network-related, please make sure to restart (reload) the network service itself along with any other service which may be impacted. In your case, I'd recommend restarting the dnsmasq and network services by issuing the following commands:

/etc/init.d/dnsmasq reload

/etc/init.d/network reload

You may issue these commands in a single line by using '&&' in between the commands. This will make sure that each service reloads one after another and if any of these commands fail, the others won't be executed. For example:

/etc/init.d/dnsmasq reload && /etc/init.d/network reload

Full list of services can be retrieved by issuing the following command via CLI (SSH/Telnet):

ls /etc/init.d/

Best regards,

Tomas. 

Best answer
by

Thank you Tomas!
I meanwhile stumbled upon a more complicated solution - 

/etc/init.d/dnsmasq restart
uci set wireless.@wifi-iface[0].user_enable=0 && uci set wireless.@wifi-iface[0].disabled=1 && uci commit && wifi
sleep 2
uci set wireless.@wifi-iface[0].user_enable=1 && uci delete wireless.@wifi-iface[0].disabled && uci commit && wifi

Yours is much cleaner, but one question -
Why do you reload dnsmasq after network? Wouldn't it allow clients to reconnect to the wifi still with the old addresses, and not reconnect again on dnsmasq reload?

by
Good point, that's a mistake on my end! Indeed, the correct logic is to reload the dnsmasq service and then the network service. I've fixed my initial reply as well, thank you for pointing that out.