IP Addresses and NAT

Started by
5 comments, last by ajoling 22 years, 8 months ago
I guess we all know that if you''re behind an NAT router that it''s almost impossible to get your IP address. I want to make a combobox that shows *all* available IP-addresses available on someone''s machine. (Like ServeU does, if some people use it here)... But I just can''t get the correct IP address. I''ve made an small HTML file that uses an Apache webserver variable to get the IP address. But this is just overkill. It should be a lot easier to do so then letting the users visit an website to find out their correct IP. Now I thought about using the "GetIpAddrTable" API call, but it will only return "192.168.0.4", and "127.0.0.1". Again no external IP address. Since many people are using Winsock (API) here, I wonder if someone is able to get it correctly? I''m using VB, but C++ Winsock is identical to VB... Almar
www.persistentrealities.com for Inline ASM for VB, VB Fibre, and other nice code samples in C++, PHP, ASP, etc.<br/>Play Yet Another Laser Game!<br/>
Advertisement
Well, the only reliable way to get their external IP address is by using some type of server that just sends it back to the machine. You can look into SNMP to query routes along the way to find their external IP, but that''s not 100% reliable as not all NAT devices support SNMP.
That was not exactly the answer I was waiting for

I''ll probably connect t a server, open an script which returns the IP address again..
www.persistentrealities.com for Inline ASM for VB, VB Fibre, and other nice code samples in C++, PHP, ASP, etc.<br/>Play Yet Another Laser Game!<br/>
Well, my question then is why do you need to know their external IP address? If they''re behind a NAT gateway and are going to be hosting a game, then it''s the client that needs to know that external IP address. All the person running the server needs to do is forward the specific ports correctly on their NAT gateway.

If they are going to be a client then their external IP address isn''t really important to them either.

Well, it''s more because of a (confirmed) bug in DX8.0(a).
If my masterserver retrieves the IP address of the connecting gameserver, it will give "192.168.0.4" for me... even if you''re connecint really over the internet, through an router. Now if the masterserver would send this to the clients, it would be an useless IP... since the client will try to connect to their own network IP(''s).

I already made an ''override textbox''... but I rather have it filled in correctly, so the user can select the correct IP immediatly. It ain''t crucial though..

The bug is fixed in DX8.1... but then everybody has to download DX8.1.. even an worse option

(btw: I''ll be away for a few days, I cannot reply on this topic )

Almar
www.persistentrealities.com for Inline ASM for VB, VB Fibre, and other nice code samples in C++, PHP, ASP, etc.<br/>Play Yet Another Laser Game!<br/>
http://msdn.microsoft.com/library/default.asp?URL=/library/techart/Nats2-msdn.htm

I''m assuming you''ve looked at that. If there is a confirmed bug in DP8, then I really think requiring DX8.1 would be a better solution than anything I can come up with for getting your external IP address. I just wouldn''t want to have to run a web server returning the client IP address just to work around a bug in DP8.
Yeah, I''ve seen that article... The Client/Server can connect perfectly, the only problem is the IP address.

Well, I''ll just leave that textbox in so that users can still ''override'' their network IP address. And later I''ll just remove it, and compile a version with DX8.1 which does it all automatically. Since DX8.1 isn''t released yet, it looks like the best solution for me.

Thanks,
Almar
www.persistentrealities.com for Inline ASM for VB, VB Fibre, and other nice code samples in C++, PHP, ASP, etc.<br/>Play Yet Another Laser Game!<br/>

This topic is closed to new replies.

Advertisement