Problem Description
I encountered numerous times network issues where I had to manually intervene and resolve them. When the root cause is always the same, you may want to automate the resolution. Beware though, don’t try to automate something that does not occur frequently enough, otherwise you spent time and effort for trivial things that don’t bring any value. When I try to automate something, it is because I am fed up doing it manually (so it is proven it can be automated) or if I want to learn something new.
In this particular case, I have VPN connections to several remote locations and one of them sits behind CGNAT and a 4G router. If, for whatever reason, I lose the VPN to that remote site, I cannot initialize the VPN connection from the central site since the remote site is ‘hidden’ behind the provider’s NAT. In other words, I don’t know its public IP address. After a few trips to the site, I realize the interface (the wlan and eth0) go down and lose their IP address. Up until know, I don’t know the reason, I suspect it has something to do with the DHCPCD service and I am planning to replace it with networkmanager service in the near future. But for now, I need to automate the network recovery. This is all in a raspberry pi running the latest raspberry OS.
Continue reading →