How to get the WAN ip address (the one assigned by VPN, not the ISP)?
Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech
-
- OpenVpn Newbie
- Posts: 5
- Joined: Thu Aug 02, 2018 9:18 pm
How to get the WAN ip address (the one assigned by VPN, not the ISP)?
Running a debian router that uses openVPN client to connect to a VPN provider.
When the tun0 is established, it runs the "update-resolv-conf" script. How do I get the public WAN ip address (the VPN's WAN address, not the iSP) inside this script? This is so I can pass the IP to a DDNS provider: "curl <ddns provider".
I tried "$ifconfig_local" and "$ifconfig_remote" but they both come up with 10.x.x.x ip addresses and not the real WAN ip address.
When the tun0 is established, it runs the "update-resolv-conf" script. How do I get the public WAN ip address (the VPN's WAN address, not the iSP) inside this script? This is so I can pass the IP to a DDNS provider: "curl <ddns provider".
I tried "$ifconfig_local" and "$ifconfig_remote" but they both come up with 10.x.x.x ip addresses and not the real WAN ip address.
-
- OpenVPN Protagonist
- Posts: 11137
- Joined: Fri Jun 03, 2016 1:17 pm
-
- OpenVpn Newbie
- Posts: 5
- Joined: Thu Aug 02, 2018 9:18 pm
Re: How to get the WAN ip address (the one assigned by VPN, not the ISP)?
Yes but when I go to whatismyip.com, it's a different IP address. I want to know that address.
-
- OpenVPN Protagonist
- Posts: 11137
- Joined: Fri Jun 03, 2016 1:17 pm
Re: How to get the WAN ip address (the one assigned by VPN, not the ISP)?
Do you mean the egress IP address of the VPN service provider once connected to their VPN ?
-
- OpenVpn Newbie
- Posts: 5
- Joined: Thu Aug 02, 2018 9:18 pm
Re: How to get the WAN ip address (the one assigned by VPN, not the ISP)?
Yes, actually let me explain what I'm trying to do.
I wrote a BASH script that calls "curl <ddns provider url> >> /usr/local/bin/ddns.log" that calls my DDNS provider.
I need this script to run everytime openVPN establishes a tunnel. I've tried putting it in as a "up cmd" in the config file and it didn't work (security level is already set to 2).
I wrote a BASH script that calls "curl <ddns provider url> >> /usr/local/bin/ddns.log" that calls my DDNS provider.
I need this script to run everytime openVPN establishes a tunnel. I've tried putting it in as a "up cmd" in the config file and it didn't work (security level is already set to 2).
-
- OpenVPN Protagonist
- Posts: 11137
- Joined: Fri Jun 03, 2016 1:17 pm
Re: How to get the WAN ip address (the one assigned by VPN, not the ISP)?
This is because in a script called by openvpn you must specify all commands in full ..
EG: "curl" must be "/usr/bin/curl"
I would also recommend you do the same for your output file name.
-
- OpenVpn Newbie
- Posts: 5
- Joined: Thu Aug 02, 2018 9:18 pm
Re: How to get the WAN ip address (the one assigned by VPN, not the ISP)?
ok, now it runs. However there is a problem.
Even though it runs "up" (which I think means the tunnel is established), the ddns provider is seeing the ISP ip address instead of the "egress vpn ip address". I think this is because even though the tunnel is "up", it's not yet "connected".
If I run the script manually after a few seconds, the ddns provider sees the "egress vpn ip address".
How do I make it "wait" or is there a separate "up" command?
Even though it runs "up" (which I think means the tunnel is established), the ddns provider is seeing the ISP ip address instead of the "egress vpn ip address". I think this is because even though the tunnel is "up", it's not yet "connected".
If I run the script manually after a few seconds, the ddns provider sees the "egress vpn ip address".
How do I make it "wait" or is there a separate "up" command?
-
- OpenVPN Protagonist
- Posts: 11137
- Joined: Fri Jun 03, 2016 1:17 pm
Re: How to get the WAN ip address (the one assigned by VPN, not the ISP)?
indeed ..jdoe87 wrote: ↑Sat Aug 04, 2018 5:41 pmHowever there is a problem.
Even though it runs "up" (which I think means the tunnel is established), the ddns provider is seeing the ISP ip address instead of the "egress vpn ip address". I think this is because even though the tunnel is "up", it's not yet "connected".
This is good security