Re: At a loss figuring out if an IP is on LAN or INET
- From: david <david@xxxxxxxxxxxxxxxx>
- Date: Sat, 29 Apr 2006 08:50:44 -0700
On 2006-04-29, Terry Olsen <tolsen64@xxxxxxxxxxx> wrote:
I don't see where the TCP vs. UDP issue comes in. Both have the source
address in the packet.
What source address is in the packet? The local, private IP? or the public
internet IP?
The IP address from which the packet arrived. In other words, for
internet hosts, the packet will contain the external public address, for
internal network hosts, the packet will contain the internal address.
This seems to be the information you're trying to handle yourself, when
in fact the network layer is already handling it for you.
More importantly, for external internet hosts what you really want is
the NATted address, and that's what the packet will contain, since a NAT
firewall will replace the source address in the header.
Maybe I just don't understand the problem. I can sorta see issue in
p2p swarming apps like BitTorrent or Kazaa where a third server needs
to keep lists of distributable IP addresses and the sender address
might not match the distributable address.
In this case though, it doesn't look like that's happening. So why
can't a node receiving a packet simply reply to the sender, without
the issue of embedding a user-defined IP address in the data.
Ok. I'm talking to multiple peers, some inside and some outside my
router. If I send out my private IP (192.168.0.14) to all peers as a
return address, then only those INSIDE my router will be able to
respond. If I send out my public internet IP to all peers, only those
OUTSIDE my router will be able to respond. I need to send the
appropriate return IP address to each peer determined by their
location relative to my router.
What I'm suggesting is don't send any IP address in your data packet.
Let the IP stack worry about putting the correct address in the
header. Unless you have special needs, this isn't something the
application layer should be worrying about.
I believe I understand now how to get the "network address" by
AND'ing the Subnet Mask with with each IP and comparing the results.
I'm going to try that.
That's going to break on any internal network with routing. In other
words, on anything larger than a very trivial home network.
I don't think I have to worry about this at all. Since I don't control
the corporate firewall at work (port forwarding & such), I wouldn't be
able to communicate outside the company boundaries anyway. I would
simply send my local IP (10.x.x.x) to all other peers.
Host 1 has address 10.0.0.1/255.255.255.0 (address/subnet)
Host 2 has address 10.0.1.1/255.255.255.0
Now these two hosts are NOT on the same subnet, in fact they must be
routed, and your algorithm will correctly identify that. But in reality
both hosts are probably behind the firewall, and you'd have to use the
internal IP addresses to communicate between them.
IAW, routed != NAT.
.
- Follow-Ups:
- Re: At a loss figuring out if an IP is on LAN or INET
- From: Terry Olsen
- Re: At a loss figuring out if an IP is on LAN or INET
- References:
- At a loss figuring out if an IP is on LAN or INET
- From: Terry Olsen
- Re: At a loss figuring out if an IP is on LAN or INET
- From: david
- Re: At a loss figuring out if an IP is on LAN or INET
- From: Terry Olsen
- Re: At a loss figuring out if an IP is on LAN or INET
- From: david
- Re: At a loss figuring out if an IP is on LAN or INET
- From: Terry Olsen
- At a loss figuring out if an IP is on LAN or INET
- Prev by Date: Re: VB 2005 express database problems
- Next by Date: Ent Library. Substitute data from app.config?
- Previous by thread: Re: At a loss figuring out if an IP is on LAN or INET
- Next by thread: Re: At a loss figuring out if an IP is on LAN or INET
- Index(es):
Relevant Pages
|