Sign in to follow this  
Followers 0
furox

IP Routing

5 posts in this topic

Let's say my computer (IP 192.168.1.100) is plugged to a switch which is plugged to a router to have Internet access (IP 212.15.100.14).

I want to know what happens when I access the Internet, for example, to visit a website:

- What will be the source address in the IP header when it is created in my computer: 192.168.1.100 or 212.15.100.14?

- What will be the source address in the IP header when it gets to the router and then to the Internet: 192.168.1.100 or 212.15.100.14?

- If the source address in the IP header is 212.15.100.14 when it reaches the web server, how will the router know to which computer send the packet received from the web server?

I'll be thankful if anybody can explain it to me, or at least tell the topics so I can search them on the Internet.

0

Share this post


Link to post
Share on other sites

given the setup you described, when you enter a URL in a web browser the browser would first see if it already knows the IP address of the domain you enter. if it does, it skips resolving the domain name and starts a connection. if it doesn't currently know the IP address of the domain (like google.com) it sends a DNS request to get it. i'm not too authoritative on DNS, but you can read more here: http://en.wikipedia.org/wiki/Domain_Name_System

after the domain name is resolved to an IP address, your computer will initiate a TCP connection with the server using the three-way handshake, and begin sending/receiving data using the TCP connection. (more on this and TCP here: http://en.wikipedia.org/wiki/Transmission_Control_Protocol ). To get from your local subnet of private IPs onto the internet filled with public IPs, routers will use network address translation ( http://en.wikipedia.org/wiki/NAT ). while your packets go from your pc to the switch then to the router, they will have a source IP in the 192.168 subnet (your computer's IP, 192.168.1.100). after the pass through the router, the router changes their source address to a publicly routable IP address (the IP you were assigned by your ISP, 212.15.100.14). this way they can travel on the internet. as your router receives responses from whatever server you've connected with, it will again use NAT to change the destination address (they're coming towards you this time) to the appropriate one, 192.168.1.100.

summary: DNS if necessary, establish TCP connection, use connection, close connection when finished. as traffic goes through the router, it uses NAT so connections will work between public and private subnets.

if you want to read about this more on your own, check out TCP/IP subnetting, CIDR notation, TCP connections, NAT, and ethernet if you want to go that deep.

0

Share this post


Link to post
Share on other sites

thanks for the information!

welcome. as always, feel free to ask questions if you don't understand something, but there's tons of info on TCP/IP and networking on the internet. wikipedia's usually a good place to start because not only do they cover the topic in good detail, but they also usually link to the RFCs in the references if you want to find out more.

0

Share this post


Link to post
Share on other sites

To get a bit more indepth, hopefully it is not too jumbled:

computer: 192.168.1.100

macaddress: aa-aa-aa-aa-aa-aa

default-gateway: 192.168.1.14

your router lan: 192.168.1.14

your router wan: 215.15.100.14

lan macaddress: aa-aa-aa-bb-bb-bb

wan macaddress: aa-aa-aa-cc-cc-cc

default gateway: 35.38.19.1 <- some upstream router

upstream router: 35.38.19.1

clientside mac-address: bb-bb-bb-bb-bb-bb

networkside mac-address: bb-bb-bb-cc-cc-cc

your dnsserver: 8.8.8.8

dns macaddress: bb-bb-bb-bb-bb-bb

google.com: 74.125.53.106

web macaddress: cc-cc-cc-cc-cc-cc

----

Basic network info:

- Packets keep the ip-address source and destination while the layer2 frames substitute in new mac-addresses for each hop.

- The same network (same-subnet) is switched instead of routed, but to reach a different network you must route the traffic.

----

You decide you want to go to google.com.

Step 1:

Your computer checks its dns cache for 'google.com', if it doesn't have it locally it sends a request to 8.8.8.8.

Assume you have it locally for now, if you don't the steps to obtain it are the same as the steps to reach google.com.

Step 2:

Your computer ANDs the ip address of the destination against the closest source network in its routing table;

If it's a different network entirely it has to go to your default gateway.

Asssuming 192.168.1.0 /24, 74.125.53.106 is a different network and you must send the packet to 192.168.1.14.

Step 3:

Your computer sends a packet to 192.168.1.14 (the default-gateway), with:

source mac: aa-aa-aa-aa-aa-aa, destination mac: aa-aa-aa-bb-bb-bb

source ip: 192.168.1.100, destination ip: 74.125.53.106; via 192.168.1.14 (based on the arp entry)

Step 4:

Your router repeats step 2-3, with its own local ip and addresses in the routing and switching tables.

It substitutes in a new source ip and keeps the destination ip, and also substitutes in new mac-addresses for the source and destination.

This is network address translation, so that you can hide multiple users behind a single gateway without the need for each of them to have an internet routeable address - you can still host services on specific ports.

source mac: aa-aa-aa-cc-cc-cc, destination mac: aa-aa-aa-bb-bb-bb

source ip: 215.15.100.14, destination ip: 74.125.53.106, via 35.38.19.1 (again, based on the arp entry)

etc.. until the packet hits a network with the same local network, and then it looks in the arp table for the mac-address that corresponds to that ip.

Step 5:

Google gets your packet, and does the reverse to respond back to you when it negotiates a 3-way-handshake, now with itself as the source ip and you as the destination; the mac-addresses change every hop.

There is also likely network address translation going on, and quite possibly vpn tunnels or ipv6-to-ipv4 could be in play. Wiki has some articles on this, and either the Comptia Network+ or the first part of the Cisco CCNA (ICND1) will have all of the information you need.

Edited by jabzor
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0