How to connect two computers directly in NAT environment?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Prasenjit Chat
    New Member
    • Jan 2011
    • 1

    #1

    How to connect two computers directly in NAT environment?

    When both computers are accessing the Internet with private IPs assigned by their ISPs ( Later translated into global public IPs by NAT), is there any way that two computers could be connected directly without any thrid-party server?

    I want to know how does Chat programs, Torrent Clients or any distributed applications handle this NAT, which discards any incoming data from the outside world to someones computer who is assigned a private IP.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    Private IPs are actually assigned either by the device itself, or the local router (Broadband Router - often provided by ISP). Although the packets going out from the device with the private IP address (EG. your PC) are designed to work in your local environment, this is encapsulated and hidden by the router, which sends it out into the big wide internet as if it were coming from itself. The router has ports facing both internally and externally, hence its ability to route traffic for you.

    Outgoing packets have their IP address AND PORT information switched (This is NAT or PAT. These stand for Network Address Translation and Port Address Translation). The router dynamically remembers all such sessions, and knows to route any traffic returned on these addresses back to the individual internal device (In this example your PC). So far relatively straightforward .

    To handle incoming traffic requests, that is those that are not responses to internal requests, but direct traffic from outside (We are now talking about the traffic that firewalls are most concerned with in order to protect the integrity of your systems so extreme care must be taken here with any configuration changes.) it is necessary to configure the router/firewall specifically to indicate which internal device and port should be the destination when external requests come in. The default behaviour would be to drop all such packets, thereby protecting your system from much harmful traffic.

    I hope this is some help.

    PS. I suspect you may have got help more quickly had you posted your question in the Network Forum in the first place. I will move it there now anyway for you.

    Comment

    • horace1
      Recognized Expert Top Contributor
      • Nov 2006
      • 1510

      #3
      Are the two computer within same NAT network, if so you can use RMI, TCP or UDP protocols so long as you know the IP addresses or domain names. If you wish to communicate from within a NAT network to the outside you can use RMI or TCP for two way communication or UDP to send information out. To access a machine within a NAT network from outside you have to configure the router to use port redirection (sometimes called port forwarding) to route incomming packets to the correct machine.

      Comment

      Working...