cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
304
Views
0
Helpful
3
Replies

TCL script : how to retrieve WAN IP address behind an ISP's box?

wma
Level 1
Level 1

Hi there,

I'd like to know if there is a way to retrieve WAN IP address of my ISP. Of course, my router (ISR4300) is not plugged straight to WAN link, else I would just perform a 'sh int G0/0/0' or the like . The interface of my router is behind an ISP box connected to the internet. Such a thing should exist, since you can get easily your WAN IP address (like IP Chicken, for example). For now, my ADSL ISP allows static IPs, so, this is simple as ABC, but future fiber ISP knows only DHCP for WAN IPs.

Idea behind this is to retrieve WAN address, and push it to my registrar (OVH), with an HTTP method - I used that a while ago when I used a 827 instead of an internet box, and it worked like a charm. Since ISP's WAN interface cannot be monitored, I guess that regular interval polling would be used for that.

Sure, things would be much more simple if could put an SFP straight into the router, but I doubt that first, IPS configuration allows that, and second, simplex SFPs do exists for Cisco routers.

Thanks for your ideas!

3 Replies 3

Hello,

since you are asking for TCL, you could try a script such as the one below on your 4300. In this example, 'whatismyip' is being used.

tclsh
set ip [exec wget -qO- http://whatismyip.akamai.com/]
puts "Current WAN IP: $ip"

Hi Georg, many thanks for your answer! It does not work, but I got the point: query Akamai and retrieve ip in plain text, and pass it to the router (brillant idea to use Akamai ). What I have is that:

NWR01(tcl)#set ip [exec wget -qO- http://whatismyip.akamai.com/]
^
% Invalid input detected at '^' marker.

Anyway, though I'm a real moron with TCL, and have scarcely used it, I will check docs/examples on my side to see where's the issue.

Thanks again!

Dan Frey
Cisco Employee
Cisco Employee

wget is a bash utility and not in tcl.   Enable guestshell on the router to enter bash environment and run commands from there.

 

INET#guestshell

[guestshell@guestshell ~]$ 
[guestshell@guestshell ~]$ ip=`curl http://whatismyip.akamai.com`
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    15  100    15    0     0    205      0 --:--:-- --:--:-- --:--:--   205
[guestshell@guestshell ~]$ echo $ip
2xx.7xx.8xx.9xx

 

There is also a python environment in guestshell that can be used for http services as well.

 

[guestshell@guestshell ~]$ python3
Python 3.6.8 (default, Dec 22 2020, 19:04:08) 
[GCC 8.4.1 20200928 (Red Hat 8.4.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

 

 

Review Cisco Networking for a $25 gift card