Archived

This topic is now archived and is closed to further replies.

Telamon

Can you control how NAT happens in a router?

Recommended Posts

Hey, I recognize that this is probably a dumb question, so please excuse my ignorance of the inner workings of routers. Game servers that sit behind routers which do Network Address Translation have difficulty retrieving their external (internet aware) IP address. This is a problem because other people need this number to connect to your session (at least if you''re using DPlay and you''re poor, so you can''t get a static IP or some kind of DNS mapping - again, I''m fuzzy about the details here). So my question is: Routers tend to assign local IP addresses to machines behind them. If I recall correctly, it''s often something like 192.0.0.* Is there any way to change the NAT so that the computer with the game server on it is assigned the same IP as the router''s external IP address? So instead of being assigned something like 192.0.0.1, it gets assigned the IP that my campus''s DHCP server assigns to the router itself? This would be really handy because then I could just use GetLocalHostAddresses to find my external IP. Is there any real reason why it couldn''t work like this? It seems like the computers on the router subnet could be assigned any IP you like. Or would I need more sophisticated piece of network hardware to accomplish this? Any input would be appreciated! This is a hard thing to research online when you don''t know more than the fundamentals. ---------------------------------------- Let be be finale of seem, seems to me. ---------------------------------------- Coding: http://www.stanford.edu/~jjshed/coding Miscellany: http://www.stanford.edu/~jjshed

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The only reliable way to get your address as seen from outside is to have another machine tell you. You first send out a packet, or a connection, and then the other machine has to send the information back.

Share this post


Link to post
Share on other sites
No, your router won''t and shouldn''t do that... Routers uses specific routing algorithms to determine which port to send packets out to and while possible to make a router that could do something like that, it''d be a fairly useless feature.

Why exactly does your server even need to know it''s external IP? Any packets sent to it will have its internal IP - that''s the job of a NATing router. If you''re having trouble with people not being able to get your external IP you either need a static IP (which you''d likely never be able to get out of a college) or use a dynamic DNS service like DynDNS (which costs money) or No-IP (which as far as I know is still free... at least, they haven''t asked for any money from me yet).

Those programs will run on your computer behind the NAT, and ocassionally send messages to the DynDNS/No-IP servers with some identifying information (so they know which DNS entries are yours). The DNS service takes your IP from that packet (post-NAT, so it''s your external IP) and then updates their DNS servers. Whenever someone requests the URL you''ve gotten from them (for example, telamon.no-ip.com) it sends them your external IP address.

Then they try to connect to your router (which is what''s sitting at your external IP) on Port and if the router has been told to forward packets on Port to your internal computer it will do so.

You never need to know your external IP and they never need to know your internal IP. You could have hundreds of computers sitting behind that one router, nobody would know, and you would only be using a single public IP address. Behold, the power of NAT.

Share this post


Link to post
Share on other sites
dyndns cost money? nah iam using it and its free, you will have to pay if you use more than 5 dyndns entrys (in one account) for the additional ones, but you will never need 5 of them...


and for the question: you dont need todo anything to get your ip(192.168...) converted to the routers ip through nat (that is how nat works...) one thing you will have todo is tell your router in some way that you are using a specified port and all packeds have to be forwarded to your machine (through this you will also prevent other apps from using this port). You dont have to waste your braincells on what ip your router or server has (use the packed src ip...), dont send the ip in the packeddata and nat will do the rest.


T2k

Share this post


Link to post
Share on other sites
oh.. okay, you''re right. dyndns.org is free for up to 5 names, cool. Quite possibly I was thinking of dyndns.com which has essentially died.

Share this post


Link to post
Share on other sites