Sign in to follow this  
Followers 0

IP Routing

5 posts in this topic

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

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: or

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

- If the source address in the IP header is 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.


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 it sends a DNS request to get it. i'm not too authoritative on DNS, but you can read more here:

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: ). To get from your local subnet of private IPs onto the internet filled with public IPs, routers will use network address translation ( ). 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, 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, 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,

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.


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.


Share this post

Link to post
Share on other sites

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


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


your router lan:

your router wan:

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

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

default gateway: <- some upstream router

upstream router:

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

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

your dnsserver:

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

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

Step 1:

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

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

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 /24, is a different network and you must send the packet to

Step 3:

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

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

source ip:, destination ip:; via (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:, destination ip:, via (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

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