You are not logged in.
Pages: 1
I finally decided to automate something that had been a bit of a time waster for me.
nano /usr/local/sbin/Killvpn
#!/bin/bash
openvpn_pid=$(pidof openvpn | awk '{print $1}')
kill $openvpn_pid
chmod +x /usr/local/sbin/Killvpn
Also you can add local host DNS resolving to the vpn kill script.
echo "search lan
nameserver 192.168.1.1" > /etc/resolv.conf
Super simple, new to awk but reading a script from GNU user pretty much taught me all I needed to know to get this working. (
found out you wont even need awk for something this simple) Thanks
Last edited by czeekaj (2020-08-07 02:05:44)
Offline
Here's how to kill openvpn in one line in terminal:
sudo pkill -f openvpn
Depending on how you run openvpn, you may not need the -f.
Last edited by GNUser (2020-08-07 19:08:41)
Offline
Also you can add local host DNS resolving to the vpn kill script.
echo "search lan nameserver 192.168.1.1" > /etc/resolv.conf
Actually, DNS changing can be better accomplished with the openvpn up and down directives as described here.
Install resolvconf packages using the following command.
apt-get install resolvconf
Add the following lines to each .ovpn file to prevent DNS leakage.
script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf
The up directive is executed when openvpn starts and forces your Devuan box to use the VPN DNS servers to prevent DNS leakage.
The down directive is executed when you kill openvpn and returns your Devuan box to using the original DNS, in your case 192.168.1.1.
The advantage of using the above method is that if you are mobile and your DNS server IP address changes, the down directive will still correctly return your DNS to the original value. Whereas, your script will incorrectly change the DNS IP address to 192.168.1.1 and you will no longer be able to browse the Internet.
Offline
Thanks for this.
I have been using chattr to prevent DNS leakage
Seems like you are doing it the proper way. I just found a way to prevent my resolve.conf from changing on me after setting it.
Thanks guys I learned a bit from you
pkill will be useful for me.
Also, as I use public Wifi often the 10.100.0.1 DNS is quite common for cisco routers. It helps me from manually having to change it all the time.
Awesome thank you very much.
Last edited by czeekaj (2020-12-18 04:26:03)
Offline
Pages: 1