/usr/sbin/ministun -t 1000 -c 1 -i tun13 stun.l.google.com:19302
Response read #0 timeout, retry
ping stun.l.google.com
PING stun.l.google.com (74.125.140.127): 56 data bytes
64 bytes from 74.125.140.127: seq=0 ttl=47 time=70.571 ms
64 bytes from 74.125.140.127: seq=1 ttl=47 time=12.742 ms
64 bytes from 74.125.140.127: seq=2 ttl=47 time=12.742 ms
64 bytes from 74.125.140.127: seq=3 ttl=47 time=12.737 ms
^C
--- stun.l.google.com ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 12.737/27.198/70.571 ms
/usr/sbin/ministun -t 1000 -c 1 -i tun13 stun.l.google.com:19302
Bind socket to device [tun13] failed! errno 19 (No such device)
78.xxx.xxx.xxx
./VPN_Client_Switch.sh status
VPN Client Status:
Client 1 Connected via 100.120.56.153 (HMA New York) VPN tunnel end-point I/P: 77.234.46.197
Checking for response (5secs) from 'http://ipecho.net/plain' to verify VPN tunnel end-point I/P: 77.234.46.197
VPN tunnel end-point I/P: 77.234.46.197
curl --connect-timeout 5 -s --interface "tun1"${VPNID} "http://ipecho.net/plain"
ping -c 4 stun.l.google.com
PING stun.l.google.com (64.233.177.127): 56 data bytes
64 bytes from 64.233.177.127: seq=0 ttl=45 time=7.559 ms
64 bytes from 64.233.177.127: seq=1 ttl=45 time=7.844 ms
64 bytes from 64.233.177.127: seq=2 ttl=45 time=7.536 ms
64 bytes from 64.233.177.127: seq=3 ttl=45 time=7.665 ms
--- stun.l.google.com ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 7.536/7.651/7.844 ms
ping -c 4 -I tun13 stun.l.google.com
PING stun.l.google.com (64.233.177.127): 56 data bytes
64 bytes from 64.233.177.127: seq=0 ttl=47 time=30.757 ms
64 bytes from 64.233.177.127: seq=1 ttl=47 time=31.356 ms
64 bytes from 64.233.177.127: seq=2 ttl=47 time=31.140 ms
64 bytes from 64.233.177.127: seq=3 ttl=47 time=30.801 ms
--- stun.l.google.com ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 30.757/31.013/31.356 ms
curl --connect-timeout 5 -s --interface "tun13" "http://ipecho.net/plain"
209.160.119.xxx
/usr/sbin/ministun -t 1000 -c 1 -i tun13 stun.l.google.com:19302
Response read #0 timeout, retry
Well fortunately at least you now have a solution for your original e-mail notification requirements.Your curl code returns the correct IP: (response partially masked in post by me)
Code:curl --connect-timeout 5 -s --interface "tun13" "http://ipecho.net/plain" 209.160.119.xxx
ministun fails:
Code:/usr/sbin/ministun -t 1000 -c 1 -i tun13 stun.l.google.com:19302 Response read #0 timeout, retry
/usr/sbin/ministun -t 1000 -c 1 -i tun11 stun.wtfismyip.com
Runt Attribute (got 2, expecting 4)
77.234.46.197
Hi @DFFRZ, @Asad Ali
Did you find any solution for this issue? Exactly the same thing is happening to me. I tried the curl command suggested by @Martineau too, but is still not working. It seems that ip is seted after this line in the log is executed: "Initialization Sequence Completed".
Thanks!
Regards!
You have to call the "gettunnelip" script from inside your script first to let it initialize the NVRAM variable.
Put this line on top of your script :
sh /usr/sbin/gettunnelip.sh 1
Change the digit as per your VPN cleint. 1 is for VPN client number 1.
This same things is happening to me as well. Running 'sh /usr/sbin/gettunnelip.sh 1' or 'curl --connect-timeout 5 -s --interface "tun11" "http://icanhazip.com"' in my ssh shell works perfectly fine but if I try to run these commands within any of my openvpn-event scripts, regardless of the sleep delay, it simply does not work. It has to be something related to the process that is executing the script. I've been messing with this for the last 8 hours and I am SO frustrated. Did you ever figure this out @maxiarg14 or anyone else?@Asad Ali Thanks for answer. Yes, that is what I´m doing, but for some reason that command is not working until the line "Initialization Sequence Completed" appears in the log, so when running the script "usr/sbin/gettunnelip" from inside my script, it returns an "unkown" ip. Now I'm not at home, but in a few hours I will post my script, so you can see it. Maybe I´m doing something wrong.
Regards
Thanks for the quick reply! That is interesting... I tried typing 'echo $trusted_ip' into my shell and it appears to be invalid/blank (and my VPN client is currently active). Ultimately, I came up with a workaround which is working fine but I still wish there was a better way of tackling the issue. For anyone coming across this thread in the future, my workaround is as follows:Yes, I spent a lot of time trying to figure out why gettunnelip doesn't work in a script called from openvpn...never could. Luckily there's an alternative. Openvpn sets an environment variable with the VPN endpoint address accessible from called openvpn scripts. Access it as
$trusted_ip
#!/bin/sh
# ------------------------------------------------------------------------
# Script Info:
# ------------------------------------------------------------------------
# Sets up a cron job to run the script that updates the DDNS address
# '****.*****.***'; it has to be done this way bc all network
# communication in any openvpn-event script fails until AFTER they are
# finished running
# ------------------------------------------------------------------------
scr_name="$(basename "$0")[$$]"
vpn_num=$(echo $(basename "$0") | grep -o -E "[0-9]+")
logger -t "$scr_name" "VpnClient${vpn_num} - Running vpnclient${vpn_num}-route-up script"
# Ensures existing cron job is deleted
cru d "vpnc${vpn_num}ddns"
# Adds a cron job to run the 'vpnclient1-ddns-update' script AFTER VPN initialization is complete
logger -t "$scr_name" "VpnClient${vpn_num} - Adding cron job 'vpnc${vpn_num}ddns' to run 'vpnclient${vpn_num}-ddns-update' within the next min"
cru a "vpnc${vpn_num}ddns" "* * * * * /jffs/scripts/vpnclient${vpn_num}-ddns-update"
#!/bin/sh
# ------------------------------------------------------------------------
# Script Info
# ------------------------------------------------------------------------
# Responsible for updating DDNS '****.*****.***' with the exit IP
# of VPN Client #1 via DynU.com's API; this script is executed via a
# cron job created in the 'vpnclient1-route-up' script
# ------------------------------------------------------------------------
scr_name="$(basename "$0")[$$]"
vpn_num=$(echo $(basename "$0") | grep -o -E "[0-9]+")
logger -t "$scr_name" "VpnClient${vpn_num} - Running $(basename "$0") script"
# Deletes cron job so it does not repeat
logger -t "$scr_name" "VpnClient${vpn_num} - Deleting cron job 'vpnc${vpn_num}ddns'"
cru d "vpnc${vpn_num}ddns"
# ------------------------------------------------------------------------
# Retrieves VPN Client #1 exit IP address
# ------------------------------------------------------------------------
logger -t "$scr_name" "Running 'gettunnelip.sh' to update nvram variable 'vpn_client${vpn_num}_rip'"
sh /usr/sbin/gettunnelip.sh $vpn_num
ip=$(nvram get vpn_client${vpn_num}_rip)
# ------------------------------------------------------------------------
# Another way to do the above task
# ------------------------------------------------------------------------
# intfc="tun1${vpn_num}"
# logger -t "$scr_name" "Running curl cmd to get exit IP address of interface $intfc"
# ip=$(curl --connect-timeout 5 -s --interface "${intfc}" "http://icanhazip.com")
# logger -t "$scr_name" "VPN Client #${vpn_num} exit IP is '${ip}'"
# ------------------------------------------------------------------------
# Dynu.com DDNS - Set '****.*****.***' to VPN Client #1 exit IP
# ------------------------------------------------------------------------
if [ "$ip" != "0.0.0.0" ] \
&& [ "$ip" != "unknown" ] \
&& [ "$ip" != "" ] ; then
hostname="****.*****.***"
nvram set "vpn_client${vpn_num}_rip"=$ip # Not needed if you got IP by running 'gettunnelip.sh'
logger -t "$scr_name" "Updating DDNS '${hostname}' to VPN Client #${vpn_num} exit IP '${ip}'"
wget -O/dev/null -q "https://api.dynu.com/nic/update?hostname=${hostname}&myip=${ip}&myipv6=no&password=**************************"
fi
I tried typing 'echo $trusted_ip' into my shell and it appears to be invalid/blank (and my VPN client is currently active).
It's only active in the environment when running scripts spawned by openvpn. In the Merlin context, that means a script tied to openvpn-event. Just openvpn running/trying in a shell won't work.Openvpn sets an environment variable with the VPN endpoint address accessible from called openvpn scripts.
Ah, gotcha. Thanks for the info!It's only active in the environment when running scripts spawned by openvpn. In the Merlin context, that means a script tied to openvpn-event. Just openvpn running/trying in a shell won't work.
Welcome To SNBForums
SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.
If you'd like to post a question, simply register and have at it!
While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!