Help Center
Managing the IVPN Linux CLI client at System Boot
The IVPN Linux CLI client does not currently offer support for a persistent firewall or automatically connecting at system boot, though these features are planned for future releases.
Using standard Linux features, it is possible to manage both the automatic connect and the firewall settings at system boot at either the user-level via crontab or the system-level using a systemd unit file.
Please use only one of these options to avoid conflicts.
User-level: crontab
-
Create a Bash script to first wait for the ivpn-service to become ready, then apply the connection options:
$ nano /home/user/bin/auto-conn-ivpn.sh #!/bin/bash while ! ps -e | grep ivpn-service > /dev/null ; do sleep 1 done /usr/local/bin/ivpn firewall -on /usr/local/bin/ivpn connect -p wg -antitracker Denmark
Press
Ctrl+x
to save the file and exit from thenano
editor.Note: The script above uses a WireGuard connection to our server in Denmark. Please feel free to use whichever connection settings you prefer. Our Command Line Client FAQ has details. -
Make the script executable:
$ chmod +x /home/user/bin/auto-conn-ivpn.sh
-
Edit the crontab and add a line with the
@reboot
timing directive plus the path to the script above. Logging is optional:$ crontab -e @reboot /home/user/bin/auto-conn-ivpn.sh > /home/user/auto-conn-ivpn.log
-
Reboot your system to confirm the IVPN Linux client connects automatically.
-
Check the log file to see the connection details:
$ cat /home/user/auto-conn-ivpn.log
To adjust the connection settings, edit the /home/user/bin/auto-conn-ivpn.sh
script. No changes to the crontab are required.
To de-activate this automatic boot-time connection, edit the crontab and comment out or remove the @reboot /home/...
line.
System-level: systemd
-
Create a Bash script with the connection options:
$ sudo nano /usr/local/bin/ivpn-autoconnect.sh #!/bin/bash /usr/local/bin/ivpn firewall -on /usr/local/bin/ivpn connect -p ovpn -antitracker Singapore
Press
Ctrl+x
to save the file and exit from thenano
editor.Note: The script above uses an OpenVPN connection to our server in Singapore. Please feel free to use whichever connection settings you prefer. Our Command Line Client FAQ has details. -
Make the script executable:
$ sudo chmod +x /usr/local/bin/ivpn-autoconnect.sh
-
Create a systemd unit file to control the autoconnect service:
$ sudo nano /lib/systemd/system/ivpn-autoconnect.service [Unit] Description=IVPN autoconnect service. After=network.target ivpn-service.service Requires=network-online.target ivpn-service.service [Service] Type=oneshot ExecStartPre=sleep 2 ExecStart=/bin/bash /usr/local/bin/ivpn-autoconnect.sh ExecStop=ivpn disconnect RemainAfterExit=yes [Install] WantedBy=multi-user.target
Press
Ctrl+x
to save the file and exit from thenano
editor. -
Enable the autoconnect service:
$ sudo systemctl enable ivpn-autoconnect.service
-
Reboot your system to confirm the IVPN Linux client connects automatically.
-
Check the autoconnect service status:
$ sudo systemctl status ivpn-autoconnect.service
To adjust the connection settings, edit the /usr/local/bin/ivpn-autoconnect.sh
script. No changes to the systemd unit file are required.
To de-activate this automatic boot-time connection, disable the autoconnect service:
$ sudo systemctl disable ivpn-autoconnect.service
Related Articles
- How do I prevent VPN leaks using iptables?
- Autostart WireGuard in systemd
- Kill Switch using the Uncomplicated Firewall (UFW)
- AVC denial with selinux
- WireGuard - "RTNETLINK answers: Operation not supported"
Still have questions?
Get in touch and we'll get back to you in a few hours.
Contact supportInterested in privacy?
Read our latest privacy news and keep up-to-date on IVPN services.
Visit IVPN Blog