lucasl
To start my openvpn server run the following: openvpn /etc/openvpn/server.conf
This works for me properly and this stop with ctrl C. I have no problems here.
For added security, I need the VPN service is enabled from the 7hs to 14hs.
To start using: openvpn /etc/openvpn/server.conf
But I can not stop with any of the following commands
# Service openvpn stop
# /usr/sbin/openvpn stop
# /etc/init.d/openvpn stop
This would be the configuration of my crontab to start and stop the VPN service on the server:
00 7 * * * /usr/sbin/openvpn /etc/openvpn/server.conf >> /etc/openvpn/openvpn.log
00 14 * * * /usr/sbin/openvpn stop >> /root/openvpn_salida.txt
I should do to automate the start and stop the service openvpn on the server?
Thanks.
maikcat
i believe you can try this:
kill -14 `ps ax | grep server.conf | grep -v grep | awk {'print $1'}`
i am sure there are prettier ways like using writepid directive to write
openvpn pid to a file and read it from there...
Michael.
lucasl
Yes. That's the only way.
I usually use kill -9 PID to kill the process.
But this way I can do without knowing hacerso PID number.
Thank you very much.
regards
dropje
Bit of ugly to use ps ax with greps etc to get the pid.. use pgrep instead:
pgrep openvpn
The reason you can't stop the openvpn service with the init script is because you didn't start it with it in the first place.
So use the init script to start/stop the daemon or use it like you do now and kill openvpn.
The other option would be to block access to your VPN with iptables in a cron.
iptables -I INPUT -p udp --dport 1194 -j DROP
and
iptables -D INPUT -p udp --dport 1194 -j DROP
for example..
lucasl
Yes dropje, that's another option.
Thank you.