Explain IP mapping to me

KingGheedora

Diamond Member
Jun 24, 2006
3,248
1
81
I think I have an idea of how it works but have never seen/read an explanation of it, so I'd like to confirm.

I'm wondering how IP mapping works, specifically when multiple IP's are assigned to one machine. Example scenario is a single IIS server running multiple websites, each website mapped to a different IP address. The server has one NIC, which has it's own IP address on the internal network as well (internal to datacenter).

There are several scenarios possible, but for now let's assume those website IP's are all public IP's, and I think this is the most basic scenario.

When an external user requests website1, public DNS points to the public IP, and that IP by internet magic, gets routed to the datacenter's network. How does the datacenter's routers/switches know to send the IP to the server where the website is hosted. I'm assuming that the router or firewall has routing tables that map the public IP for website1 to the internal IP of the IIS server's NIC, is that correct? And then on the IIS server itself, IIS has registered a listener for the IP of website1?

I might have more Q's, but that's all for now.
 

spidey07

No Lifer
Aug 4, 2000
65,469
5
76
Normally each host has only one IP address and you use host headers to direct the url to the correct site. You could have a single host with thousands of websites without any problems. This is just a setting on the web server so that each unique URL goes to a different site. www.site-a.com has it's root in /site-a. www.site-b.com has it's root in /site-b

But how the packet actually gets to the host is like you think, it's all just routing. What your talking about a public IP and it's associated private/internal IP then you're talking about network address translation or NAT which is normally done on a firewall.
 

KingGheedora

Diamond Member
Jun 24, 2006
3,248
1
81
Thanks. I'm familiar with host headers, but i'm asking specifically about situations in which those are NOT used. You can map each website in a web server to a different IP address. And other server software like SMTP servers also can run multiple virtual MTA's inside the same software instance, each V-MTA being mapped to a different IP.
 

spidey07

No Lifer
Aug 4, 2000
65,469
5
76
A host can have many IP addresses, although it's not normally good practice to do so. How the devices know to send packets to that server based on IP address then is a function of ARP. A router/firewall broadcasts to the subnet "hey, who has 10.5.5.5" and the server respondis with his MAC address, the layer2 address of the NIC. When the router ARPs for 10.5.5.50, the server also responds with the same MAC.

Then the router/firewall knows how to send packets, which are now encapsulated layer2 frames to the host.
 

Kadarin

Lifer
Nov 23, 2001
44,296
16
81
Thanks. I'm familiar with host headers, but i'm asking specifically about situations in which those are NOT used.

This is just an FYI incidental to the original question.

When dealing with the context of the Web and the HTTP protocol (the Layer 7 protocol used for Web communication), host headers are ALWAYS used in HTTP/1.1. For example note the following GET request, sent by my browser to cnn.com:


GET / HTTP/1.1
Host: www.cnn.com
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive