IP address in applescript?

is it possible for me to grab the address of my router in applescript? do i have to run some sort of shell script to do it? thanks to anyone who can help.

If you mean the IP address that the router shows to the world, I think that the only way to do this is to contact a remote computer, unless you can hack something together that will communicate with the router’s web interface (this would be different for most routers). All of the shareware apps that I’ve seen appear to contact a server.

I don’t have a router installed, but this script returns the IP address of my system…

do shell script ("/sbin/ifconfig en0 | head -3 | grep 'inet ' | cut -d' ' -f 2")

you can just copy/paste the below command in the terminal app to see if it works for you.

/sbin/ifconfig en0 | head -3 | grep 'inet ' | cut -d' ' -f 2

This shows the broadcast IP address

/sbin/ifconfig en0 | head -3 | grep 'broadcast ' | cut -d' ' -f 6

On my system, which has a router, these all return the internal network IP supplied to my Mac by the router (via DHCP), such as 192.168.0.101. All machines on my local network are invisible to the Internet and the router is the only device that uses the IP address assigned by my ISP. So, as far as I know, the only way to obtain the router’s IP address (the one assigned by the ISP) is to go outside of the network, which means relying on a server on the Internet. There are various web sites available for this. :slight_smile:

Most routers can be configured via a web browser. Now, to change settings, you need to login, but for my SMC Barricade I don’t need to login just to see the current IP Address. In fact, all I need to do is the following in the Terminal:
curl http://192.168.123.254/status.htm

Your router may be different, especially if it is not an SMC. I’ll leave reading the HTML source returned to find the IP Addresses inside as an excercise for the reader. :slight_smile:

Curl rulz!

The HTML admin pages for my D-Link router are driven by JavaScript so maybe I’ll poke around in the source to see if I can use curl. :rolleyes: