Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
To help understand this situation Google for articles on NAT. –  John Gardeniers Feb 25 '10 at 11:31
add comment

closed as off topic by sysadmin1138 Oct 5 '11 at 16:45

Questions on Server Fault are expected to relate to professional server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

3 Answers

up vote 6 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
    
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). –  Borek Feb 25 '10 at 21:09
    
Really? You live on another planet? Where I live I can get a VPS from every hoster on the planet. –  TomTom Sep 25 '10 at 5:53
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.