I would like to add ARP entry for an entire subnet (

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

But the command returns:

SIOCSARP: Invalid argument

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

Is there any way to do what I want ?

Something like: arp -v -i p4p1 -s MAC_OF_P4P2


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 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 to my interface p4p1: ip route add dev p2p1.

=> p4p1 doesn't know Who has Tell

I need to set an ARP entry to link 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
    Feb 20 '18 at 4:25
  • If it's not possible, how about adding dynamically an entry when one IP is used?
    – Alexis
    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
    Feb 20 '18 at 4:45

What you are trying to do is set up a route. You question doesn't say whether this 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 via, when your system needs to talk to any machine in it's going to look up the MAC address for, and send the traffic to that MAC address. Nowhere in the outgoing packet does it have the IP address

Thus your solution is simple:

ip route add via

^ where 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 via dev p2p1
  • I added some diagrams. I think your solution is equivalent as what I've already done: ip route add dev p2p1. Still the p2p1 doesn't know who has 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
    Feb 20 '18 at 23:54

Support for proxy arp entries for networks (netmask not equal 0xffffffff) was dropped in Linux 2.2. It is replaced by automatic proxy arp setup by the kernel for all reachable hosts on other interfaces (when forwarding and proxy arp is enabled for the interface).

Reference: https://manpages.courier-mta.org/htmlman7/arp.7.html

Maybe you could try the setting.

echo 1 > /proc/sys/net/ipv4/conf/"interface"/proxy_arp

The interface will check route table relate interface subnet and sending arp proxy packet.

  • Wow that seems nice and might be the solution. I'll accept it once I tested it. Thanks!
    – Alexis
    Oct 31 '21 at 7:33

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.