-1

I know that we can add arp entry in windows using arp -s IP MAC I need a command to add such entry for a specific interface if I have many

While I have those two interfaces Interface: 10.243.16.11 --- 0xe Interface: 192.168.1.179 --- 0x17

ahmed saber
  • 1
  • 1
  • 2
  • It's not really a programming question. However, in anticipation of the question being moved to SuperUser, I'll provide one regardless. 'Cause that's just the sort of nice guy I am :-) – paxdiablo Feb 23 '21 at 01:14

2 Answers2

1

The arp command under Linux has a -i flag for specifying the interface but the Windows one is slightly different.

If you run arp on its own, you'll see how to do it:

ARP -s inet_addr eth_addr [if_addr]
ARP -d inet_addr [if_addr]
ARP -a [inet_addr] [-N if_addr] [-v]

You need to provide the IP address if_addr for the specific interface you want to affect. For example:

C:\Users\Pax>arp -a

Interface: 192.168.0.72 --- 0x1c
  Internet Address      Physical Address      Type
  192.168.0.1           80-20-da-a0-f9-3d     dynamic

Interface: 172.23.128.1 --- 0x33
  Internet Address      Physical Address      Type
  172.23.143.255        ff-ff-ff-ff-ff-ff     static

C:\Users\Pax>arp -s 192.90.90.90 80-20-da-a0-f9-33 172.23.128.1

C:\Users\Pax>arp -a

Interface: 192.168.0.72 --- 0x1c
  Internet Address      Physical Address      Type
  255.255.255.255       ff-ff-ff-ff-ff-ff     static

Interface: 172.23.128.1 --- 0x33
  Internet Address      Physical Address      Type
  172.23.143.255        ff-ff-ff-ff-ff-ff     static
  192.90.90.90          80-20-da-a0-f9-33     static

You can see there that the arp entry has been added to the cache for the specific interface.

paxdiablo
  • 854,327
  • 234
  • 1,573
  • 1,953
0

Another way for accomplishing the same behavior but more aligned with Windows server management is using netsh command utility (for some networking technologies like ARP and DHCP it works in regular Windows10 and Windows11 as well)

netsh interface ipv4 add neighbors "Interface Name" "IP" "MAC" store=persistent

For example:

netsh interface ipv4 add neighbors "Ethernet" "10.243.16.12" "12-34-56-78-9a-bc" store=persistent
netsh interface ipv4 add neighbors "WiFi" "192.168.1.180" "12-34-56-78-9a-bc" store=persistent
Joru
  • 1
  • 2