$ip isn't populated by the server though, that's the bug. mIRC is grabbing the actual public IP from out of the blue when you're behind a lan. $ip should evaluate to whatever your computer's assigned IP is, not evaluating twice, once to you for your local IP, and then out to everyone else with your public IP.