-1

Assume that PC A, IP 10.49.1.1 wants to send a packet over IP address 10.70.70.1 to PC B, IP 10.49.1.8. PC B receives the packet and sends it back over 10.70.70.1 to PC A. Both PCs are connected via a switch. It's important that PC A is connected via 10.70.70.1 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 10.70.70.1"? – Henrik Jul 3 '17 at 10:33
  • The application on PC A and PC B shall send and receive packets on 10.70.70.1. In detail: PC A is a NTP-Client, PC B is NTP-Server. PC B can not have the IP-Address 10.70.70.1, therefore, I thought routing via 10.70.70.1, like 10.49.1.1 <-> 10.70.70.1<-> 10.49.1.8, is possible or not? – Sam Jul 3 '17 at 10:45
  • 2
    And what do you mean with "send and receive packets on 10.70.70.1". 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 10.70.70.1. – Sam Jul 3 '17 at 10:48
  • And what does "via switch on 10.70.70.1" mean? Do you have a managed switch that has that ip? – Henrik Jul 3 '17 at 11:00
2

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      |
| 10.70.70.1   10.49.1.1 |   | 10.49.1.8 |
+------------------------+   +-----------+
    |             |                |
----+             +----------------+
switch                  switch
10.70.70.0/24           10.49.1.0/24

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

 ip route add 10.70.70.0/24 dev eth0 via 10.49.1.1

then PC B will send all packet to 10.70.70.* first to PC A, and in particular it will reach PC A under 10.70.70.1 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.

1

It's not very clear what are you trying to accomplish, since 10.49.1.1 and 10.49.1.8 can talk each other in the same subnet. The switch works at layer 2, so 10.70.70.1 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 10.0.0.0/8, 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 10.75.75.1 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 10.0.0.0/8 as gateway to PC A and PC B will solve it? – Sam Jul 3 '17 at 11:16
  • 10.0.0.0/8 is a network segment, not an ip address. You want put 10.70.70.1 as gateway for the destination ip address on both PC, but this won't work. If they are in the same subnet (10.0.0.0/8), 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.