What's new

How to disconnect/reconnect from OPEN VPN Client using Batch File

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Can anyone confirm that the script I provided is correct? I tried to modify it to account for multiple devices, but I'm not sure if I did it properly. Also, how do I run "chmod 755"?
 
Can anyone confirm that the script I provided is correct? I tried to modify it to account for multiple devices, but I'm not sure if I did it properly. Also, how do I run "chmod 755"?
just copy paste this command in your router telnet/ssh session
Code:
chmod 755 /jffs/scripts/vpn-route-1.sh
reboot afterwards and test
 
just copy paste this command in your router telnet/ssh session
Code:
chmod 755 /jffs/scripts/vpn-route-1.sh
reboot afterwards and test

I tried pasting it in my session, but all I got was an error. What now?

Here's the error:

"Error changing directory to chmod 755 /jffs/scripts/vpn-route-1.sh"

Command 'cd "chmod 755 /jffs/scripts/vpn-route-1.sh"'
failed with return code 2 and error message
-sh: cd: line 53: can't cd to chmod 755 /jffs/scripts/vpn-route-1.sh.
 
How do I access the command line in my SSH session? I was just pasting the line directly into my session without the command line. Perhaps that accounted for the above error?
 
I tried pasting it in my session, but all I got was an error. What now?

Here's the error:

"Error changing directory to chmod 755 /jffs/scripts/vpn-route-1.sh"

Command 'cd "chmod 755 /jffs/scripts/vpn-route-1.sh"'
failed with return code 2 and error message
-sh: cd: line 53: can't cd to chmod 755 /jffs/scripts/vpn-route-1.sh.
Notice the 'can't cd to...' ?
The command should not start with 'cd' !
 
Alright, so I finally managed to access the command line and input the code. Unfortunately, whenever I turn on the VPN client all my devices go through it instead of only the ones I've specified.

*sigh* This is getting tiring. Can anyone tell me what's wrong with this script?

#!/bin/sh


ip route flush table 11
ip route del default table 11


ip route flush cache


tun11_ip=$(ifconfig tun11 | grep 'inet addr:'| cut -d: -f2 | awk '{ print $1}')


ip route add default via $tun11_ip dev tun11 table 11
ip rule add from 192.168.xx.xx table 11
ip rule add from 192.168.xx.xx table 11

ip route flush cache


DNS_SERVER="208.67.222.222 208.67.220.220"
for ip in $DNS_SERVER
do
iptables -t nat -A PREROUTING -s 192.168.xx.xx -p udp --dport 53 -j DNAT --to $ip
iptables -t nat -A PREROUTING -s 192.168.xx.xx -p tcp --dport 53 -j DNAT --to $ip
iptables -t nat -A PREROUTING -s 192.168.xx.xx -p udp --dport 53 -j DNAT --to $ip
iptables -t nat -A PREROUTING -s 192.168.xx.xx -p tcp --dport 53 -j DNAT --to $ip
done


iptables -I FORWARD ! -o tun11 -s 192.168.xx.xx -j DROP

exit 0
 
Still having trouble here guys. I put the above script into jffs/scripts and input the code into my command line, but I'm still having problems. Whenever I start up the VPN client everything goes through it instead of only the devices I've specified. Could something be wrong with the script?

Also, if I add "route-nopull route-up /jffs/scripts/vpn-route-1.sh" to my VPN client config everything goes through my standard ISP and I can't get back on the VPN client. Any thoughts?
 
Still at a loss guys. At this point, I'm thinking of going back to the original scripts I was using, since at least with those everything behaved as it should as far which devices were on the VPN and which weren't. Any additional info is much appreciated.
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top