How to assign the location of a device automatically through the IP?
That functionality is not available. You may want to suggest a feature request here to be considered for a future release.
the only work round to this is creating a smart label with IP Address begins with x.x. or IP address contains = and then when agents are deployed or a machine moves between IP address space it will pick up and drop off the location smart label, when i say location Smart label i just name them something like Location - - Site A, Location - - Site B etc. works well for replication share association as well for local file share access.
You could actually create a ticket rule to assign the location based on IP address. If you take the suggestion above to create smart labels, you can then use the SQL from the Smart label in a ticket rule, you will just need to know the location Asset ID to then assign when the rule is run. Simple!!