Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

twoodcc

macrumors P6
Original poster
Feb 3, 2005
15,307
26
Right side of wrong
so, let's just use macrumors for an example.

let's say that macrumors.com is on one server, and forums.macrumors.com is on another server.

can they be on the same local network? and if so, how would it know to go to the forums server when someone went to the forums.macrumors.com site?

i thought with port forwarding, all port 80 would go to one machine on the local network. am i correct?

and so then, each server would have to have it's own external static ip address?
 
DNS allows each "name" address like macrumors.com or forums.macrumors.com to resolve to a different IP address. In this case both servers would have external IP addresses.

It would be possible for both sites to be on the same server. In that case, both names would resolve to the same address. HTTP requests include the address that was requested, so that the server knows which page to send.

It is also possible to have one server act as a sort of traffic controller, directing incoming traffic to different servers in order to balance the load. Large sites typically use variations of this strategy.
 
so with DNS, you could route images.macrumors.com to the images server? or would it need it's own external ip address (sorry, just to clarify)
 
Each name in DNS resolves to a single IP address, which in general is an external address, otherwise no one from the outside will be able to get in. This is a simple one-to-one mapping, like a phone book. DNS itself doesn't do any routing; it just returns an IP address when you give it a name.

To address your original question, if you only have one external IP address and you set your router to forward port 80 to some local address, you are correct that all port 80 traffic will go to that address. There are ways to have a router or a server redirect requests based on the name that was used, even though they all have the same IP address. In general, this only works for HTTP because HTTP has a special header that includes the name that was used. Sites that are set up this way might have multiple servers dealing with requests to the same IP address. However, to the client it looks like a single server doing all of the work.
 
Each name in DNS resolves to a single IP address ... DNS itself doesn't do any routing; it just returns an IP address when you give it a name.

Not totally correct. DNS can resolve to multiple IPs:

Code:
Name:    www.l.google.com
Addresses:  64.233.169.104, 64.233.169.147, 64.233.169.99, 64.233.169.103
Aliases:  www.google.com

These IPs can be on very separate networks. DNS will then rotate these addresses, usually in a round robin fashion, but some DNS servers can check the load of the boxes to determine which IP is the primary.

So, DNS doesn't do any IP routing per se, but it can route traffic to different networks in an indirect fashion.
 
Each name in DNS resolves to a single IP address, which in general is an external address, otherwise no one from the outside will be able to get in. This is a simple one-to-one mapping, like a phone book. DNS itself doesn't do any routing; it just returns an IP address when you give it a name.

To address your original question, if you only have one external IP address and you set your router to forward port 80 to some local address, you are correct that all port 80 traffic will go to that address. There are ways to have a router or a server redirect requests based on the name that was used, even though they all have the same IP address. In general, this only works for HTTP because HTTP has a special header that includes the name that was used. Sites that are set up this way might have multiple servers dealing with requests to the same IP address. However, to the client it looks like a single server doing all of the work.

thanks for the reply. so you can have multiple sites on different servers, but the same external ip.
 
thanks for the reply. so you can have multiple sites on different servers, but the same external ip.

Yes, you would then use the VirtualHost directive in Apache or Host Headers in IIS. You can then just open port 80 to the machine.

Keep in mind this adds load to your server. Depending on the amount of traffic, it can impact it significantly.
 
Yes, you would then use the VirtualHost directive in Apache or Host Headers in IIS. You can then just open port 80 to the machine.

Isn't this for multiple sites on the same server?

To use a single IP for multiple servers, you would use a gateway (there are software and hardware based gateways) to direct traffic to the various servers inside your network.
 
Isn't this for multiple sites on the same server?

To use a single IP for multiple servers, you would use a gateway (there are software and hardware based gateways) to direct traffic to the various servers inside your network.

Yes, you're right. I misread the reply. That's what I get for posting while sick. Ack!
 
thanks for the reply. so you can have multiple sites on different servers, but the same external ip.


Yes, a common way to do this is to have the box that gets all the requests running a proxy, like Squid, which knows which servers to talk to deeper in your network for different content.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.