2

I've got a fairly standard home network with a modem from my ISP, which is connected to a router which then provides NAT to about 3 PCs and laptops. There's a possibility to obtain one public IP from my ISP.

Now I'd like to add a web server to this setup. What I'm concerned about is how the web server will play along with the rest of the network.

Say that my ISP gives me a public IP address of 1.2.3.4. In my home router, I think that I'll need to setup a rule saying that requests to 1.2.3.4:80 should be routed to my web server's internal IP, say 192.168.1.1.

However, if I sit at my home PC and try to load google.com, Google will probably see my PC's IP (which might be 192.168.1.2) as 1.2.3.4 (my public IP) and will send the response to this IP. When the IP packets reach my router, it will see it as a packet to 1.2.3.4:80 and I'm worried that it will be routed to my home web server which would obviously prevent my PCs from working correctly.

I'm sure there's some hole in the reasoning above and that it is possible to have both regular desktops and a web server behind one public IP. So if anyone could explain where my thinking is wrong and how it really works, it would be greatly appreciated.

1
  • To help understand this situation Google for articles on NAT. Feb 25, 2010 at 11:31

3 Answers 3

6

You're almost right there. Except that the replies coming from Google will not see it as a packet to 1.2.3.4:80. They will see it as 1.2.3.4:XXXXX where XXXXX is a random port number in the unprivileged range.

Also, the router will keep a list of connections in its routing table and route the return packet correctly to your desktop computer 192.168.1.2 instead of your home server.

What you want to do is a fairly straightforward and normal setup.

1

Keep in mind that frequently, for residential ISPs, your Acceptable Use Policy or Terms Of Use will forbid servers. My ISP actually blocks ports 25 & 80 (and a few others) making it impossible to run a server w/o a port designation on it.

0

The question you didn't ask, is "should I host a webserver on my home network", and the answer is almost always "no". The technology exists to do it, but unless this is a very small, hobby-ish website (or just for learning purposes) you are much better of paying $5-$10 a month and getting many, many more magnitudes of throughput and redundancy from a company that is setup to do it.

So can, yes? Should you? almost never.

2
  • Where I live, you can't get a VPS for $5-$10 a month (you can get a shared hosting for this price which is very different from what I want). Feb 25, 2010 at 21:09
  • 1
    Really? You live on another planet? Where I live I can get a VPS from every hoster on the planet.
    – TomTom
    Sep 25, 2010 at 5:53

Not the answer you're looking for? Browse other questions tagged .