Marketo silently collects the IP address when a lead fills out a form.
That information is accessible through the Activity Log.
Assuming the IP is relevant for GeoLocation or user-defined activities, you can either use SOAP API to retrieve that information of add a JavaScript to save the IP and GeoLocation to custom fields.
The SOAP API call would be getLead or getMultipleLeads
getLeadActivity is also a good fit
You can then use syncLead or syncMultipleLeads to find the IP and location to custom fields
A small JavaScript allows to read and save that information in one go when the form is saved:
function myIP() {
if (window.XMLHttpRequest) xmlhttp = new XMLHttpRequest();
else xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("GET","http://api.hostip.info/get_html.php",false);
xmlhttp.send();
hostipInfo = xmlhttp.responseText.split("\n");
for (i=0; hostipInfo.length >= i; i++) {
ipAddress = hostipInfo[i].split(":");
if ( ipAddress[0] == "IP" ) return ipAddress[1];
}
return false;
}