On 12/12/17 18:44, Mark Rogers wrote:
I don't know if this is Pi specific, I assume it's just standard Debian.
I'm using Raspbian Stretch.
Suppose I have a working wireless connection.
I can change wireless configuration in /etc/wpa_supplicant/wpa_supplicant.conf to remove the working details and then use "wpa_cli reconfigure" to take effect. Except that I remain connected to the wifi that I no longer have settings for, and cannot force it to disconnect.
What is the correct way to force the change to have effect other than reboot?
On a related note, how do I change the IP configuration for the cabled network and have that take effect? Making changes to /etc/dhcpcd.conf works after a reboot but I can't reliably make it work without rebooting. (Restarted dhcpcd will add a new IP address, but won't remove old ones and doesn't seem to let me revert to DHCP reliably either.)
In both cases, making a connection seems easier than dropping one.
Mark
OK, so you're headless, so I'm assuming connection via ssh (or telnet). So if you sucessfully stop the network, you'll lose your connection. So the first thing to do is start a SCREEN session. In case you don't know, screen is a command you can install (with sudo apt-get install screen), and when you run it, it creates a new command window within the current terminal, but you can "detatch" from it. The big advantage is, if you lose your ssh session for some reason, the screen will continue to run and you can re-attach to it.
so run
screen
Then I what springs to mind is ifup and ifdown which bring up and take down the network interface respectively, similar to what was discussed here: https://askubuntu.com/questions/441619/how-to-successfully-restart-a-network...
So, if you put this on one line. sudo ifdown eth0 && *sudo* ifup eth0
replace eth0 with the name of the interface, wireless or wired. Screen will protect you from the loss of the ssh connection, and the && will execute the second command if the first one succeeds, so if the network goes down, the network should be brought up again.
ifup and ifdown may have been replaced by newer commands, or may not be installed by default. Some commands seem to have been replaced by the newer general purpose "IP" command.
Regarding the IP address, is this any use? https://www.computerhope.com/issues/ch001078.htm
Also, if you have a dhcp server, even though the client is releasing the IP address, it could be that the dhcp server sees the same machine reconnecting to it, and says "I'll give you the same ip address as you're already in my lease table", so the ip address may not change. I have certainly experienced this behaviour with dnsmasq before. If that's the case, you have to persuade your dhcp server to release or expire the address leases.
Hope that helps.
Steve
ps. to re-attach to a screen session, just type screen -r. If you have multiple screen sessions running it will list them, and you can do screen -r 1234 (where 1234 is the number at the begining of the long screen name). If there is just one screen session, you will automatically reattach. To manually temporarily detatch, use ctrl-A, D. Or type exit to close the screen.