1

I would like to add ARP entry for an entire subnet (10.50.0.0/16).

I tried : arp -v -i p4p1 -s 10.50.0.0 MAC_OF_P4P2 netmask 255.255.0.0 pub

But the command returns:

arp: SIOCSARP()
SIOCSARP: Invalid argument

No problem if I add one by one: arp -v -i p4p1 -s 10.50.0.1 MAC_OF_P4P2

Is there any way to do what I want ?

Something like: arp -v -i p4p1 -s 10.50.0.0/16 MAC_OF_P4P2

Story:

I have 3 interfaces: eth0, p4p1 and p4p2.

p2p1 and p2p2 are connected through a device but let's say like a wire.

We have multiple servers with A.B.x.x in the network that is connected to Eth0.

From the system, I would like to access to A.B.x.x:

  1. Through Eth0 directly: ping A.B.X.X no problem, it does automatically

enter image description here

  1. Through p2p1 -> external device/wire -> p2p2 and then redirect to Eth0 : ping 10.50.X.X

enter image description here

In that case, I need to create virtual IPs 10.50.0.0/16 that will be same as A.B.0.0/16 but through the p4p* interfaces.

Packets need to keep 10.50.x.x as IP source/destination, only when it reaches eth0, the IP will be translated to A.B.X.X.

Let's do it step by step.

  1. I route 10.50.0.0/16 to my interface p4p1: ip route add 10.50.0.0/16 dev p2p1.

=> p4p1 doesn't know Who has 10.50.0.152? Tell 10.0.0.1

I need to set an ARP entry to link 10.50.0.0/16 to p4p2.

  • I'm not certain what you're trying to accomplish here. What is the ultimate goal for this setup? Are you implementing some sort of loopback? Adding fake ARP entries almost certainly isn't what you're wanting. – ErikF Feb 20 '18 at 4:18
  • It's complicated to explain what's the ultimate goal. I just need to assign a subnet IPs to an interface. This interface is not connected to a network but to a device. – Alexis_FR_JP Feb 20 '18 at 4:25
  • If it's not possible, how about adding dynamically an entry when one IP is used? – Alexis_FR_JP Feb 20 '18 at 4:27
  • If you're assigning a subnet to an interface, that sounds more like forwarding to me, in which case you should be using adding a route, not using ARP at all. Is this more accurate? – ErikF Feb 20 '18 at 4:36
  • I edited my post. I've already added the routing rules. 10.50.x.x is a "virtual/alias" to say go through a specific interface(p2p1). But p2p1 is lost because it doesn't know which has this IP. – Alexis_FR_JP Feb 20 '18 at 4:45
0

What you are trying to do is set up a route. You question doesn't say whether this 10.50.0.0/16 subnet exists on the destination device, or behind the destination device, but it really doesn't matter. As far as your machine is concerned they are both exactly the same.

When you add a route to your routing table, what you are saying is to route all traffic for the destination subnet to the MAC address of the device with the given IP. For example, with ip route add 10.50.0.0/16 via 1.2.3.4, when your system needs to talk to any machine in 10.50.0.0/16 it's going to look up the MAC address for 1.2.3.4, and send the traffic to that MAC address. Nowhere in the outgoing packet does it have the IP address 1.2.3.4.

Thus your solution is simple:

ip route add 10.50.0.0/16 via 1.2.3.4

^ where 1.2.3.4 is the IP of the device owning that MAC address 00:XX:XX:XX:XX:XX. If you've got multiple interfaces on the same subnet (which is likely a bad idea, but not always), you can specify the outgoing interface:

ip route add 10.50.0.0/16 via 1.2.3.4 dev p2p1
  • I added some diagrams. I think your solution is equivalent as what I've already done: ip route add 10.50.0.0/16 dev p2p1. Still the p2p1 doesn't know who has 10.50.0.0/16 then cannot route packets properly. (Checked with wireshark) My problem is not routing problem but MAC/ARP problem since it does properly work if I add ARP entries manually for each 10.50.x.x. – Alexis_FR_JP Feb 20 '18 at 23:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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