473,503 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Desitnation mac address and ip for machine behind gateway

1 New Member
If I want to send a packet to another system and there are two gateways(mine, and thiers) what would be the destination MAC address be? Would it be to my router, their router, or their system? And what would be the IP address destination be? MY first guess would be my router.
Oct 17 '11 #1
1 1870
Banfa
9,065 Recognized Expert Moderator Expert
OK the routers are presumably doing NAT (Network Address Translation), i.e. the router is connected to 2 networks and as packets pass through it it translates the addresses in the packet from 1 network to the other. The router itself has 2 addresses, 1 on each network.

If you connect to a web-server on the internet what happens is
  • Your computer sends the request to your router (which is in your computers network configuration as its gateway address)
  • Your router sees the request, assigns a port for the connection, stores a record in an internal table matching the port it assign and its external IP address with your computers IP address and the port your computer used. Replaces your computers address and port in the packet being sent with its own and forwards the packet onto the destination.
  • The packet may traverse several more NAT routers doing the same thing with-in you ISPs network before reaching the internet but we'll ignore that it just adds more layers of the same thing.
  • The packet arrives at the web-server which sends reply to the senders address in the packet, that is the address and port provided by the router.
  • The packet arrives at your router, it checks in its internal tables for a record matching its external IP address and port number it received on, which it finds so it substitutes the ip address and port in finds in that record (the ip and port of your computer) back into the packet as the destination and forwards it onto your computer on the internal network which receives it and displays the data in your browser.

This is all very well the problem is that if you connect to someone else's router you will connect to its external address (assuming it is visible to the internet/network) but the router will have no entry in its internal tables telling it where to forward the packet to, it will be unable to do anything.

There is a way round this that most routers support, you program the router with a permanent port redirection, for example you program it for forward everything received on port 42321 to a specific ip address and port on the internal network. Obviously this has to be the ip address and port for the receiving computer. Then when the router receives an external connection and packets on that port it can forward the packets to the correct destination.

Of course that is rather dependent on the router being visible on the internet either using DNS (having an assigned URL) or having a static IP address (unlikely) or you can use something called dynamic DNS which accounts for the changing ip address of the router and keeps a url pointing at it.
Oct 18 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
18566
by: Darren Kirby | last post by:
Hello list: I am writing a small app in python which tracks the kernel banner at kernel.org and downloads newer kernel version(s) (if there are any). I am using GeoIP to set the download to a...
2
1188
by: bob the yob | last post by:
Is this possible or should I set a cookie with md5 session id and login time and date.
1
1690
by: roger beniot | last post by:
Is there anyway to get the external IP Address of a gateway/router that a small LAN is connected to. I currently have a variety of linkSys and Netgear gateways that I have a variety of windows LANs...
7
21267
by: Privacy Advocate | last post by:
//crossposted to: comp.lang.javascript, alt.comp.lang.javascript in an effort to get factual answers from JavaScript experts// Simply put; Is it possible to obtain the real (actual) IP address of...
3
8970
by: roger beniot | last post by:
I would like to figure out how to detect an IP address change for an XP/Win2K3 machine that is leasing an IP via DHCP (and do it in C#)... Is there any event that indicates an IP address...
1
1563
by: Terry Petty | last post by:
I want to write a program that gets the leased IP address off of my DSL router and then tells a remote machine what that address is so that machine can find it. The remote machine on the web...
0
328
by: Herbie | last post by:
I am trying to retrieve my WAN IP address from behind a Linksys router I have tried this but it only retrieves my Local IP address Dim MyIP As IPHostEntry =...
8
4346
by: google_groups3 | last post by:
Below is a snippet of code I am using. I want to set the IP, subnet and default gateway of my local computer via code. However, when I do it, I get a "not found" (error number 5) error on the...
0
1534
by: bweaver4usenet | last post by:
Hi, all. I need some help getting a client up and running. Client Issue Client is using vc++ 6 and the Soap Tkt. Our web service is built with c# vs.net 2003. Can someone refer me to a sample I...
14
4026
by: John Kotuby | last post by:
Hi all, I have a situation where a Web Server at an install site does not currently have a publically registered Domain Name associated with the site. This requires that the a user access the...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7357
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7012
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1522
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
402
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.