tags:

views:

798

answers:

3

Host 1: 10.10.0.1

Host 2: 10.10.1.2

Mask is both: 255.255.255.0

How to send a packet from Host 1 to Host 2?

A: 

If you can make out -- Both the computers are on different subnets.

Do a "Logic AND: on IP and Mask:

1st gives - 10.10.0.0 and 2nd gives - 10.10.1.0. These two are the network addresses of the subnet. You need to send the packet to the router of the other subnet so that it can get delivered

OTOH, Can you tell where exactly has this situation arise. Knowing the real world scenario can help us to solve the problem more effciently

Routing

If you want to have a sound knowledge of routing, then you may want to check this reply on newsgroup comp.os.linux.networking dealing with routing

Manish Sinha
Yes,I know they are on different subnets.
Mask
There must be a solution for two hosts in different subnets to send packets,right?
Mask
Can you explain the situation in real life where you facing this. It would be more clear for me to understand and give the answer.
Manish Sinha
Mask, I edited the answer, check that link. BTW you shouldn't need to do anything as such. The routers should take care of it themselves using their own routing and discovery algorithms and related concepts.
Manish Sinha
@Manish Sinha,some routers support the feature of sending packets across subnets,but some don't.So I need a general solution.
Mask
@Manish Sinha,the real life situation is when I want to shut down my remote computer while in labrary.
Mask
Can you access the NAT interface of your router? There should be a section called NAT or Routing or Forwarding. It should be probably in http://RouterIPAddress/main.html as I had in all the routers I used.You can add routing information from there. Choose the range of IP address and the subnet to forward to. I havn't tried it out myself.
Manish Sinha
Yeah. That is a nice example. BTW Your router runs on Linux? If yes, can you access the shell via telnet. I could do that in all the routers I used.
Manish Sinha
A: 

Set the default gateway of Host 1 to a gateway machine that is on both the 10.10.0/24 network and the 10.10.1/24 network. Then enable IP forwarding on the gateway machine.

You can't send the packet directly unless they are really on the same physical network. If they are on different physical subnets what MAC address would you send the packet to? There isn't one - because Host 2 isn't on the same physical network - that's why you send it to gateway instead.

If Host 1 and Host 2 are on the same physical network then you aren't looking for a general solution. In that case you can send an ARP request and then send the packet to the MAC address you get the reply from and it will arrive at Host 2 - the same way TCP/IP packets are usually sent over Ethernet to hosts on the same network.

atomice
Oh,this is not a general solution!
Mask
What do you mean by 'general' solution? This is how TCP/IP is designed. If you want to send a packet to a different subnet you need to use a router or gateway.
atomice
A: 

On your PC or router, you can add routes to other networks. So if you wanted a route out a particular port on your PC or network, you could add a route which specifies that all packets addressed to that destination network/host get sent out a particular interface of your choice.

Naturally the packets getting to their destination rely on a route back as well, so you'll need to add one for each direction.

In Windows, you can do this on the command line with the route command. Type route ? for details.

On Allied Telesis networking routers, for example, you could use the add ip route command if you have access to the router's config.

If you can provide an example of the system you're using and the layout, we may be able to give more information that will make it even simpler for you to use.

Mark Mayo