1: $ip is script, or don't I get the point on that contradiction
2: If you seem to know the code so well, that you can say how long it take, why are you not adding it yourself. What you can't see, you can't possibly know.
3: $ip is set using the method setup in the "local info" section of the setup screen, and also controled via the "/localinfo" command.
You can force value using the command, and via the setup screen.
Try switching the lookup mode in the "local info" screen.
Script it all yourself. Using script, you can totaly skip the need for $ip, and it wouldn't even take much code. In fact, with such a small script, it would take you on 2 mins.