I am having trouble restarting network services.
I made a very simple shell script (OpenVPN kill switch) that checks sockstat every 60 seconds to see if OpenVPN is running, if not, it runs the command `ifconfig ue0 down' (not tun0, the VPN device, but the ethernet connection).
It works just fine, but once this script kills the internet, I cannot get it back.
I have tried running:
But that doesn't even give me the ability to connect back through SSH on my LAN. Even though when I run `ifconfig ue0' I can see the IP, 192.168.0.101, which is the IP I use to connect with.
I have tried:
But that does nothing ether. I cannot connect through SSH over LAN or even ping www.google.com, it just says the hostname does not resolve. (Right after I run the command, I can ping www.google.com just fine, but after a few seconds it goes back to saying cannot resolve host)
I also tried:
and
Once again, right after I run the command I am able to ping www.google.com, but a few seconds later it goes back to not being able to resolve hostname.
The only thing that fixes this is a complete reboot.
Here is the kill switch shell script in case it is relevant
Edit:
The issue was that after I ran the kill switch I would ctrl-z and background job it. When openvpn lost connection and the script dropped ue0, it would disappear from the `$ jobs' list.
BUT when I logged in as root and ran `ps -e', the script was still running. So every time that I restarted the network, it kept killing it.
I made a very simple shell script (OpenVPN kill switch) that checks sockstat every 60 seconds to see if OpenVPN is running, if not, it runs the command `ifconfig ue0 down' (not tun0, the VPN device, but the ethernet connection).
It works just fine, but once this script kills the internet, I cannot get it back.
I have tried running:
Code:
# ifconfig ue0 up
I have tried:
Code:
# /etc/rc.d/netif restart && /etc/rc.d/routing restart
I also tried:
Code:
# dhclient ue0
Code:
# /etc/rc.d/dhclient ue0 restart
The only thing that fixes this is a complete reboot.
Code:
# reboot
Here is the kill switch shell script in case it is relevant
Code:
while [ true ]; do # infinite loop
var2="$(sockstat | grep openvpn)"
leng=${#var2}
if [ "$leng" != "0" ]
then
echo "OPENVPN IS [ON] | DO NOTHING"
else
echo "OPENVPN IS _OFF_ | KILL INTERNET"
ifconfig ue0 down
fi
sleep 60
done
Edit:
The issue was that after I ran the kill switch I would ctrl-z and background job it. When openvpn lost connection and the script dropped ue0, it would disappear from the `$ jobs' list.
BUT when I logged in as root and ran `ps -e', the script was still running. So every time that I restarted the network, it kept killing it.