How can I add an active arp entry on Win 7
I can't see to find a way to add an active/dynamic arp entry.
This all started with old Win32 exe that calls the SetIpNetEntry API to create a dynamic/active arp entry as part of a process to setup the IP address on some embedded hardware. the SetIpNetEntry api returns a success code but no entry is created. (This code of course works fine on Win XP.)
I then tried to create one by hand via
netsh interface ip add neighbors interface=10 address="IpAddr" neighbor="MacAddr" store=active
This creates and arp entry but the type created is permenent. It seems to just ignore the store=active.
At this point I can't seem to find a way from a command line or API to create a active/dynamic entry. I don't want a permenent entry since if the setup program has a problem I don't want this assignment left on the system forever. I just need it for about 15 seconds to assign an IP address.
11 Answer
C:\>arp
Displays and modifies the IP-to-Physical address translation tables used by
address resolution protocol (ARP).
ARP -s inet_addr eth_addr [if_addr]
ARP -d inet_addr [if_addr]
ARP -a [inet_addr] [-N if_addr] -a Displays current ARP entries by interrogating the current protocol data. If inet_addr is specified, the IP and Physical addresses for only the specified computer are displayed. If more than one network interface uses ARP, entries for each ARP table are displayed. -g Same as -a. inet_addr Specifies an internet address. -N if_addr Displays the ARP entries for the network interface specified by if_addr. -d Deletes the host specified by inet_addr. inet_addr may be wildcarded with * to delete all hosts. -s Adds the host and associates the Internet address inet_addr with the Physical address eth_addr. The Physical address is given as 6 hexadecimal bytes separated by hyphens. The entry is permanent. eth_addr Specifies a physical address. if_addr If present, this specifies the Internet address of the interface whose address translation table should be modified. If not present, the first applicable interface will be used.
Example: > arp -s 157.55.85.212 00-aa-00-62-c6-09 .... Adds a static entry. > arp -a .... Displays the arp table.So, something like arp -s 157.55.85.212 00-aa-00-62-c6-09 will add an entry to the ARP cache. It should be flushed eventually, it won't survive a reboot.