Persistent static ARP entries on Windows, is it possible?

I am currently running coLinux configured in "ndis-bridged" networking mode, on a machine whose wireless networking card or driver seems incapable or unwilling to accept non-broadcast layer 2 traffic, or traffic not destined for the wireless card's primary MAC address.

After figuring out this was the problem, I tried configuring the coLinux interface to have the same MAC address as the host machine. Magically, networking started to function. Unfortunately only a single problem remains: the host machine cannot talk to the coLinux instance, even though the rest of the LAN can.

I figured out that by adding a static ARP entry to the host for the coLinux instance's IP address(es), I could accomplish full connectivity in bridged mode, even though the wireless card/driver didn't want to play along.

Despite the hackishness of this setup, I would like to keep it for a few reasons, primarily of which is IO performance for the coLinux instance. This brings me to a problem: persisting the ARP entries on the host machine.

I have searched the web, but have been unable to find the WinNT equivalent of /etc/arp from UNIX. Does such a file exist? I suspected somewhere in the registry, but alas, my searches thus far have been fruitless.

My only alternative is to run a batch file at startup to recreate the ARP entries using the arp command line tool, but this, ironically, seems hackish. :)

Thanks.


Solution 1:

netsh interface ipv4 add neighbors "Local Area Connection" 10.1.1.1 12-34-56-78-9a-bc

this will create a static arp entry that survives reboots. be careful adding the entries though, as you may not be able to remove them without a hotfix:

https://support.microsoft.com/en-us/kb/2718830

Solution 2:

netsh is no longer the preferred method for network interface management on a Windows system. Where possible, you should use Windows Powershell or Powershell Core. First you need to find out the interface index of the interface you wish the ARP cache entry to apply to:

Get-NetAdapter

Which returns:

Name      InterfaceDescription                    ifIndex Status       MacAddress         LinkSpeed
----      --------------------                    ------- ------       ----------         ---------
Wi-Fi     Intel(R) Dual Band Wireless-AC 8260          18 Disconnected 12-34-56-AB-CD-EF     6 Mbps
Ethernet  Intel(R) Ethernet Connection (2) I219-…       9 Up           78-90-12-GH-IJ-KL     1 Gbps

This is a list of your network adapters. Take note of the ifIndex property for the network adapter in question. For me, I am using my Ethernet adapter so I will use ifIndex 9 in my example.

To create a static ARP cache entry for that interface:

New-NetNeighbor -InterfaceIndex 9 -IPAddress '192.168.0.10' -LinkLayerAddress '0000120000ff' -State Permanent

Which returns:

ifIndex IPAddress      LinkLayerAddress      State       PolicyStore
------- ---------      ----------------      -----       -----------
9       192.168.0.10   00-00-12-00-00-ff     Permanent   PersistentStore

This will set persistent ARP cache entries that survive a reboot. You can reboot, then double-check by running this:

Get-NetNeighbor -InterfaceIndex 9 -IPAddress 192.168.0.10

Which returns:

ifIndex IPAddress     LinkLayerAddress   State      PolicyStore
------- ---------     ----------------   -----      -----------
9       192.168.0.10  00-00-12-00-00-FF  Permanent  ActiveStore

You can remove the entry we just created by running this:

Remove-NetNeighbor -InterfaceIndex 9 -IPAddress '192.168.0.10'

You will be prompted for confirmation twice, once to remove the entry from the Active store, and once for the Persistent store. Confirm Yes to for both to remove the entry completely. You can omit the -InterfaceIndex parameter to remove the entry from all interface stores.

Solution 3:

You should be able to use arp -s command in order to add a static entry to the ARP table

arp -s 157.55.85.212 00-aa-00-62-c6-09 .... Adds a static entry.