- Home /
How can i get real "extern" IP address ?
I make a multi player game and i need to display the ip address of the server. But i got a problem, sometimes (not everytime but often), when the server just connect, the Network.player.externalIP returns me my local ip address (192.168.x.x).
When i go to http://www.whatismyip.com/ and ask my friend to join me on this address, it works, so the server got a real "external IP".
I guess it's because at first time, the server is initialized on local network, and in a second time, few frames later, the network get the external ip. But the Network.player.externalIP seems always contains the local address, not the "real" address.
Is there a way to refresh the externalIP variable, or something ? Or an other way to get the real IP ?
Answer by Dreamora · Apr 22, 2013 at 11:04 AM
You will need to write a small webrequest against whatsmyip and alike to get the external LAN address.
There is no way to get the external IP address thats external to your network if you are within a local lan behind a router as external ip is the external ip of your computer, not your network.
The alternative is to not use direct IP connects and instead use a master server whichs purpose is exactly this kind of task as well as NAT punchthrough
Thanks, i think i'm going to do this ! I don't use a NAT because i don't want a master server :) (For the moment though.)
Answer by Lionious · Apr 22, 2013 at 12:02 PM
if you mean you need realy server to play with your friends in internet (Not Lan) then im in Right Pleace!
:) Yea Why not you can download Hamachi is VPN Program you got Room then you invite your friends to your Hamachi program then when they join your room in Hamachi they tybe the address in your Hamachi Program and the port will be 26500 :) Have fun with your friend! :)
Name : Ali - Lionious - Multiplayer Games Designer :)
Good luck !
Nope nope that wasn't my question at all :p $$anonymous$$y network works perfectly, it's just a "displaying" problem. Usually, Unity gives the "real" IP with the Network.player.externalIP variable, but some time it just return local IP. And i display this address because the "creator" needs to give this address to his friend for joining him. Like on $$anonymous$$inecraft.
But thanks for the tip, i love hamachi too :p