Help with subnet ip and DHCP values

Hi all,
I searched over the forum and I’ve learned how to get the IP address and the router IP but nothing about the subnet.
There is a way to get this info?
I would like also to know if is possible whileI use DHCP setting to change the router IP.

You could do it a complex way of getting the router table and getting parsing the data. system_profiler is an command line utility who can give system information (including network information). The beauty of system_profiler is that it can return property list data which can be turned into records using system events. Here an example that returns an interface in the form of an record with all it’s information, including subnet, of the first ip_assigned interface.

set plistData to (do shell script "system_profiler SPNetworkDataType -xml")

tell application "System Events"
	set plistRoot to make new property list item with properties {text:plistData}
	set theRecord to value of plistRoot
end tell

repeat with interface in _items of item 1 of theRecord
	if ip_assigned of interface = "yes" then return contents of interface
end repeat

To answer your second question: This can be best done by telnet or if there is an rpc/api protocol for the router. Another simple but also cumbersome way is using curl and do your login with the correct requests to the right URLs to do your actions.

DJ Bazzie Wazzie,
thanks for the detailed information and for the script. I could not ask for better.