How to Send Packets Between Two IP Hosts on Differ

2019-06-03 19:56发布

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?

标签: networking ip
3条回答
姐就是有狂的资本
2楼-- · 2019-06-03 20:09

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

查看更多
smile是对你的礼貌
3楼-- · 2019-06-03 20:23

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.

查看更多
甜甜的少女心
4楼-- · 2019-06-03 20:26

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.

查看更多
登录 后发表回答