jotyGill / openpyn-nordvpn

Easily connect to and switch between, OpenVPN servers hosted by NordVPN on Linux (+patch leakes)
GNU General Public License v3.0
628 stars 114 forks source link

How to autostart? #217

Open waleedqq opened 5 years ago

waleedqq commented 5 years ago

Trying to run this on startup but can't get it working. If I run the command openpyn au -t 10 --p2p or --country-code au --max-load 70 --top-servers 10 --pings 3 --p2p I connect to the VPN and can confirm this using "curl http://ipinfo.io/ip" (is there any other way?)

But when I run sudo systemctl enable openpyn a symbolic link was created the first time, but when I populate the openpyn.service with the parameters above and reboot my raspberry pi I am still not connected? Moreover if I run sudo systemctl start openpyn nothing happens, I do not connect to the VPN and I press cnrtl+C to cancel the operation

Jorman commented 5 years ago

You've to use -d in order to update the systemd service

-d, --daemon Update and start Systemd service openpyn.service, running it as a background process, to check status "systemctl status openpyn",

Do you have tried it?

waleedqq commented 5 years ago

screenshot_20181120-234323

I rebooted the pi and issued another curl command and the IP had reset back to my default public IP....

Jorman commented 5 years ago

but you don't start it after sudo openpyn au -t 10 --p2p -d try sudo systemcts start openpyn

PS. do you have configured it with --init, before do all?

waleedqq commented 5 years ago

Yes I started the first time with --init, typing in my credentials but didn't know how to pass the default parameters through my formatting was not working.

When I try

sudo systemcts start openpyn the cursor goes to the next line without any prompt or other text. During that time there is no messages or errors and if I create a new session the IP does not change. I'm baffled at this issue lol.

screenshot_20181121-050505

Jorman commented 5 years ago

maybe a status can indicate why dont start. If your system have journalctl you can see more log Use 2 session of putty and in one type journalctl -u openpyn.service -ef then in the other one try to start openpyn and in the 1st one you can see what happen I don't use a raspberry so maybe you've to adapt some command in order to work

waleedqq commented 5 years ago

That didn't work, no output from journalctl -u openpyn.service -ef

Is there anyway to check that the VPN is active other than checking my public IP address?

Jorman commented 5 years ago

you have to look at system log, search about your system, maybe you've only to install it

waleedqq commented 5 years ago

ok for a fresh install, how do I get it auto start? can you tell me that much?

Jorman commented 5 years ago

We need to understand why won't start, so log are needed. Without log I can't tell you so much

jotyGill commented 5 years ago

what version is this? check by running openpyn -v if it is not 2.7.5 upgrade by sudo python3 -m pip install openpyn --upgrade re initialise sudo openpyn --init try connecting openpyn au . kill it. then sudo openpyn au -d

paste logs cat /var/log/openpyn/openpyn.log cat /var/log/openpyn/openpyn-notifications.log

waleedqq commented 5 years ago

Reset the Pi and Followed your instructions exactly. I am running 2.7.5. Any help would be appreciated :)

cat /var/log/openpyn/openpyn.log

pi@raspberrypi:~ $ cat /var/log/openpyn/openpyn.log
2019-01-04 12:01:36,827 [INFO] To see usage options type: "openpyn -h" or "openpyn --help"
2019-01-04 12:04:52,699 [ERROR] There are no servers that satisfy your criteria, please broaden your search.
2019-01-04 12:05:11,237 [SUCCESS] CONNECTING TO SERVER au255 ON PORT udp
2019-01-04 12:05:11,336 [SUCCESS] Your OS 'linux' Does have '/sbin/resolvconf', using it to update DNS Resolver Entries
2019-01-04 12:06:39,084 [SUCCESS] CONNECTING TO SERVER au257 ON PORT udp
2019-01-04 12:06:39,125 [WARNING] Desktop notifications don't work when using 'sudo', run without it, when asked, provide the sudo credentials
2019-01-04 12:06:39,170 [SUCCESS] Your OS 'linux' Does have '/sbin/resolvconf', using it to update DNS Resolver Entries
2019-01-04 12:27:03,430 [NOTICE] The Following config has been saved in openpyn.service. You can Run it or/and Enable it with: 'sudo systemctl start openpyn', 'sudo systemctl enable openpyn'
[Unit]
Description=NordVPN connection manager
Wants=network-online.target
After=network-online.target
After=multi-user.target
[Service]
Type=simple
User=root
WorkingDirectory=/usr/local/lib/python3.5/dist-packages/openpyn/
ExecStartPre=/bin/sleep 5
ExecStart=/usr/local/bin/openpyn au --max-load 70 --top-servers 10 --pings 3 --p2p
ExecStop=/usr/local/bin/openpyn --kill
StandardOutput=syslog
StandardError=syslog
[Install]
WantedBy=multi-user.target

2019-01-04 12:27:03,926 [NOTICE] Starting Openpyn by running 'systemctl start openpyn'
To check VPN status, run 'systemctl status openpyn'
2019-01-04 12:27:26,944 [INFO] Shutting down safely, please wait until process exits
2019-01-04 12:41:15,596 [INFO] To see usage options type: "openpyn -h" or "openpyn --help"
2019-01-04 12:41:31,364 [SUCCESS] CONNECTING TO SERVER au194 ON PORT udp
2019-01-04 12:41:31,526 [SUCCESS] Your OS 'linux' Does have '/sbin/resolvconf', using it to update DNS Resolver Entries
2019-01-04 12:41:58,614 [NOTICE] The Following config has been saved in openpyn.service. You can Run it or/and Enable it with: 'sudo systemctl start openpyn', 'sudo systemctl enable openpyn'
[Unit]
Description=NordVPN connection manager
Wants=network-online.target
After=network-online.target
After=multi-user.target
[Service]
Type=simple
User=root
WorkingDirectory=/usr/local/lib/python3.5/dist-packages/openpyn/
ExecStartPre=/bin/sleep 5
ExecStart=/usr/local/bin/openpyn au --max-load 70 --top-servers 10 --pings 3
ExecStop=/usr/local/bin/openpyn --kill
StandardOutput=syslog
StandardError=syslog
[Install]
WantedBy=multi-user.target

2019-01-04 12:41:58,959 [NOTICE] Starting Openpyn by running 'systemctl start openpyn'
To check VPN status, run 'systemctl status openpyn'
2019-01-04 12:48:54,865 [INFO] To see usage options type: "openpyn -h" or "openpyn --help"
2019-01-04 12:49:09,789 [WARNING] Some packet loss while pinging au134, skipping it
2019-01-04 12:49:13,763 [SUCCESS] CONNECTING TO SERVER au277 ON PORT udp
2019-01-04 12:49:13,838 [SUCCESS] Your OS 'linux' Does have '/sbin/resolvconf', using it to update DNS Resolver Entries
2019-01-04 12:49:33,051 [NOTICE] The Following config has been saved in openpyn.service. You can Run it or/and Enable it with: 'sudo systemctl start openpyn', 'sudo systemctl enable openpyn'
[Unit]
Description=NordVPN connection manager
Wants=network-online.target
After=network-online.target
After=multi-user.target
[Service]
Type=simple
User=root
WorkingDirectory=/usr/local/lib/python3.5/dist-packages/openpyn/
ExecStartPre=/bin/sleep 5
ExecStart=/usr/local/bin/openpyn au --max-load 70 --top-servers 10 --pings 3
ExecStop=/usr/local/bin/openpyn --kill
StandardOutput=syslog
StandardError=syslog
[Install]
WantedBy=multi-user.target

2019-01-04 12:49:33,352 [NOTICE] Starting Openpyn by running 'systemctl start openpyn'
To check VPN status, run 'systemctl status openpyn'

cat /var/log/openpyn/openpyn-notifications.log

pi@raspberrypi:~ $ cat /var/log/openpyn/openpyn-notifications.log
2019-01-04 12:05:12,716 [ERROR] Notify 0.7 not found, expected on a non-gui os
2019-01-04 12:06:40,449 [WARNING] Openpyn Initiating connection (If stuck here, try again)
2019-01-04 12:06:40,644 [INFO] Openpyn Connected! to au257.nordvpn.com
2019-01-04 12:27:26,941 [INFO] Openpyn Disconnected, Bye.
2019-01-04 12:27:26,949 [INFO] Shutting down safely, please wait until process exits
2019-01-04 12:41:32,961 [ERROR] Notify 0.7 not found, expected on a non-gui os
2019-01-04 12:49:15,259 [ERROR] Notify 0.7 not found, expected on a non-gui os