Assume that PC A, IP wants to send a packet over IP address to PC B, IP PC B receives the packet and sends it back over to PC A. Both PCs are connected via a switch. It's important that PC A is connected via with PC B.

How can I setup PC A (Linux) to route the packet to PC B and vice versa?

closed as unclear what you're asking by Rui F Ribeiro, Anthon, GAD3R, Stephen Rauch, Anthony Geoghegan Jul 3 '17 at 16:38

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    What do you mean with "over IP address"? – Henrik Jul 3 '17 at 10:33
  • The application on PC A and PC B shall send and receive packets on In detail: PC A is a NTP-Client, PC B is NTP-Server. PC B can not have the IP-Address, therefore, I thought routing via, like <-><->, is possible or not? – Sam Jul 3 '17 at 10:45
  • 2
    And what do you mean with "send and receive packets on". Why can't A and B communicate directly? We need more information. – Johan Myréen Jul 3 '17 at 10:46
  • Because, the requirement say: PC A is connect to PC B via switch on – Sam Jul 3 '17 at 10:48
  • And what does "via switch on" mean? Do you have a managed switch that has that ip? – Henrik Jul 3 '17 at 11:00

Networking doesn't work the way you think it works. IP address are assigned to network interfaces, not PCs, and not programs. LAN segements (connected via a switch) must have a common IP prefix.

So you can have situation like this:

+------------------------+   +-----------+  
|          PC A          |   |   PC B    |
|                        |   |           |
| eth1         eth0      |   | eth0      |
| |   | |
+------------------------+   +-----------+
    |             |                |
----+             +----------------+
switch                  switch 

In that case, PC A can send packets to PC B using, and PC B can send packets to PC A using as destination. If PC B has a route like

 ip route add dev eth0 via

then PC B will send all packet to 10.70.70.* first to PC A, and in particular it will reach PC A under if some application is bound on all network interfaces, or on this particular interface.

Is that what you wanted?

If not, please explain in detail what applications you are trying to get to cooperate in what manner, and why do you think you need two IP addresses for PC A.


It's not very clear what are you trying to accomplish, since and can talk each other in the same subnet. The switch works at layer 2, so might be an ip address solely for the purpose of management, and is not involved in the communication at Layer 3. Just plug PC A and PC B into two ports of the switch in the same VLAN (untagged), and it works. .: Francesco

  • The default broadcast range for 10.x.x.x is, so anything with address 10.* is mutually on-link. – countermode Jul 3 '17 at 11:14
  • My question is clear, there exist two PCs, which are in the same subnet, but they shall also send and receive packets via different IP address. I know it make no sense but, if I add to PC B I cant reach this IP Address from PC A. – Sam Jul 3 '17 at 11:15
  • @countermode Thanks for the hint, I will check it! So, adding as gateway to PC A and PC B will solve it? – Sam Jul 3 '17 at 11:16
  • is a network segment, not an ip address. You want put as gateway for the destination ip address on both PC, but this won't work. If they are in the same subnet (, still the host will not go through a gateway. – Francesco Colista Jul 3 '17 at 13:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.