Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Software] crontab record to establish IPsec vpn connection

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
marchello
Posts: 60
Joined: 2013-10-08 08:47

[Software] crontab record to establish IPsec vpn connection

#1 Post by marchello »

Hi all,

I'm trying to set crontab record to establish IPsec vpn connection on system boot:

Code: Select all

crontab -l
* * * * * /usr/sbin/ipsec status | /bin/grep -q 'ESTABLISHED' || /usr/sbin/ipsec restart
@reboot /usr/sbin/ipsec restart
@reboot /usr/local/bin/python3.10 -m pip install requests requests_ntlm
@reboot /usr/local/bin/python3.10 -m pip install --upgrade pip
@reboot /bin/sleep 60 && /usr/sbin/ipsec status | /bin/grep -q 'ESTABLISHED' || /usr/sbin/ipsec restart
None of them work for me. As you can see, I have also added few pip commands just to make sure they worked in crontab (they did).

But manual command run works for me:

Code: Select all

/usr/sbin/ipsec status | /bin/grep -q 'ESTABLISHED' || /usr/sbin/ipsec restart
Just in case, here is how I determine it didn't work:

Code: Select all

/usr/sbin/ipsec status

[empty response]
This is how I determine it actually did work:

Code: Select all

/usr/sbin/ipsec status
Security Associations (1 up, 0 connecting):
       myvpn[1]: ESTABLISHED 15 seconds ago, 172.18.0.3[172.18.0.3]...REMOTE_IP_ADDRESS[REMOTE_IP_ADDRESS]
       myvpn{1}:  INSTALLED, TUNNEL, reqid 1, ESP in UDP SPIs: cd0b3ccc_i f8833716_o
       myvpn{1}:   172.18.0.0/16 === 192.168.238.0/24
(REMOTE_IP_ADDRESS is a placeholder)

Code: Select all

PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
Please advise.

Post Reply