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 permanently add a route? #211

Closed Jorman closed 5 years ago

Jorman commented 5 years ago

Hi, because of my configuration I've to add a static route ip route add 10.8.0.0/24 via 10.0.0.1 dev bond0

I don't know what is better to add this route when the connection go up

Any idea?

Jorman commented 5 years ago

I edited the service and I added the line that I need, but I think in case of upgrade this line will be replaced with the original one

[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 it --max-load 70 --top-servers 10 --pings 3 --p2p -o "--mute-replay-warnings --up 'ip route add 10.8.0.0/24 via 10.0.0.1 dev bond0' --down 'ip route del 10.8.0.0/24'"
ExecStop=/usr/local/bin/openpyn --kill
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=openpyn

[Install]
WantedBy=multi-user.target

@jotyGill There's any other method to add one default route?

Jorman commented 5 years ago

I don't know why but now this don't work anymore, maybe because I use a debian system, I see that --up is already used. @jotyGill do you know any other method to add some extra route? If I don't add this route I can't reach the nas that run openpyn over my openvpn server.

Any idea?

Jorman commented 5 years ago

Ok, it was simple!

[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 it --max-load 70 --top-servers 10 --pings 3 --p2p
ExecStartPost=/sbin/ip route add 10.8.0.0/24 via 10.0.0.1 dev bond0
ExecStop=/usr/local/bin/openpyn --kill
ExecStopPost=/sbin/ip route del 10.8.0.0/24
StandardOutput=syslog
StandardError=syslog
[Install]
WantedBy=multi-user.target

I simply added ExecStartPost= ExecStopPost=

So if the service successfully start, the ExecStartPost are executed, the same during the stop phase