Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #4945
| From | "sl@exabyte" <sb5309@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: PHP socket and NAT |
| Date | 2012-02-23 21:04 +0800 |
| Organization | albasani.net |
| Message-ID | <ji5dhu$lfb$1@news.albasani.net> (permalink) |
| References | <ji4v4e$lnm$1@news.albasani.net> <4f4615aa$0$6915$e4fe514c@news2.news.xs4all.nl> <4f461a60$0$6942$e4fe514c@news2.news.xs4all.nl> |
>> NAT typically is used to change IP-addresses (and maybe port). >> If A and B are in the same LAN I expect they can address each other >> directly. >> For example: >> A IP: 192.168.178.22 >> B IP: 192.168.178.25 >> >> Once you go outside your LAN, you (might) need NAT. >> >> And sockets have little to do with NAT. >> A IP package arrives at a certain IP on a certain port: If some >> socket is listening on that port on that machine, the package will >> be handled by the listening process. >> >> NAT itself is performed by routers and such, not by some service >> listening to a port. >> >> SO in short: No you have to care about it. >> >> Disclaimer: If you are talking IP6, things are different. >> >> Regards, >> Erwin Moller >> > > An additional example of NAT that makes things clear. > This is how it was explained to me when I wanted to know about NAT. > > Suppose you have 10 computers on your LAN, and 1 internet gateway > (some ADSL modem for example). > All you 10 computers can connect to the internet because they use the > routers IP address as the gateway. > > The router has an INTERNAL (LAN-side) IP address. > Let's say this LAN-IP is 192.168.178.1 > > The router also has an EXTERNAL (Internet-side) IP address. > Let's say internet-side IP is 69.147.94.94. (I made the numbers up) > > Now, suppose a few people on the LAN are visiting some websites. > Suppose compA has IP address 192.168.178.22. (On the LAN) > Suppose compA has IP address 192.168.178.50. (On the LAN) > > CompA (192.168.178.22): requests www.google.com > CompB: (192.168.178.50)requests www.php.net > > The router receives these requests from the LAN side, and sends the > requests to www.google.com and www.php.net. > The servers from Google and PHP answer the requests, and send them > back to the router's IP address (being 69.147.94.94). > > Now the problem: How should the router handle these answers? Should it > send them to 192.168.178.22 or 192.168.178.50, or even another IP on > the LAN? > > This is where NAT comes into the picture. > It works like this: > 1) Router receives request from 192.168.178.22 (=LAN)for > www.google.com. 2) Router thinks up some random port that is not is > use, eg 33000. 3) Router stores this portnumber (33000) in a table > together with the requesting LAN IP-address (192.168.178.22). > 4) Router sends the request to www.google.com TOGETHER with the > instruction to answer on port 33000. > 5) When Google answers, the router looks up the portnumber, ans sees > what (internal) IP-address made this request. This way the router can > see which internal IP-adress made what request because they all get > random assigned portnumbers. > > That is NAT in short. > > So I don't expect you have to worry about that in your case. > This example clears the air. So the key is the router comes up with random port number, and the reply specifies that port number. Thanks a lot.
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
PHP socket and NAT "SL" <sb5309@hotmail.com> - 2012-02-23 16:58 +0800
Re: PHP socket and NAT Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-02-23 11:32 +0100
Re: PHP socket and NAT Captain Paralytic <paul_lautman@yahoo.com> - 2012-02-23 02:41 -0800
Re: PHP socket and NAT Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-02-23 11:53 +0100
Re: PHP socket and NAT Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-02-23 11:52 +0100
Re: PHP socket and NAT "sl@exabyte" <sb5309@hotmail.com> - 2012-02-23 21:04 +0800
Re: PHP socket and NAT The Natural Philosopher <tnp@invalid.invalid> - 2012-02-23 13:37 +0000
Re: PHP socket and NAT The Natural Philosopher <tnp@invalid.invalid> - 2012-02-23 11:40 +0000
Re: PHP socket and NAT Jerry Stuckle <jstucklex@attglobal.net> - 2012-02-23 08:00 -0500
Re: PHP socket and NAT "sl@exabyte" <sb5309@hotmail.com> - 2012-02-23 21:09 +0800
Re: PHP socket and NAT Captain Paralytic <paul_lautman@yahoo.com> - 2012-02-23 05:19 -0800
Re: PHP socket and NAT The Natural Philosopher <tnp@invalid.invalid> - 2012-02-23 13:53 +0000
Re: PHP socket and NAT Captain Paralytic <paul_lautman@yahoo.com> - 2012-02-23 06:25 -0800
Re: PHP socket and NAT Michael Fesser <netizen@gmx.de> - 2012-02-23 18:28 +0100
Re: PHP socket and NAT The Natural Philosopher <tnp@invalid.invalid> - 2012-02-23 20:42 +0000
Re: PHP socket and NAT "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-02-24 11:58 +0100
Re: PHP socket and NAT "SL" <sb5309@hotmail.com> - 2012-02-24 00:03 +0800
Re: PHP socket and NAT The Natural Philosopher <tnp@invalid.invalid> - 2012-02-23 20:44 +0000
Re: PHP socket and NAT "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-02-24 12:07 +0100
Re: PHP socket and NAT The Natural Philosopher <tnp@invalid.invalid> - 2012-02-24 13:22 +0000
Re: PHP socket and NAT Tim Streater <timstreater@greenbee.net> - 2012-02-24 14:20 +0000
Re: PHP socket and NAT The Natural Philosopher <tnp@invalid.invalid> - 2012-02-24 15:39 +0000
Re: PHP socket and NAT Tim Streater <timstreater@greenbee.net> - 2012-02-24 18:53 +0000
Re: PHP socket and NAT The Natural Philosopher <tnp@invalid.invalid> - 2012-02-24 21:04 +0000
Re: PHP socket and NAT Tim Streater <timstreater@greenbee.net> - 2012-02-24 21:41 +0000
Re: PHP socket and NAT "Peter H. Coffin" <hellsop@ninehells.com> - 2012-02-26 12:50 -0600
Re: PHP socket and NAT Erwin Moller <erwinmollerusenet@xs4all.nl> - 2012-02-23 14:37 +0100
Re: PHP socket and NAT The Natural Philosopher <tnp@invalid.invalid> - 2012-02-23 13:50 +0000
csiph-web