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.
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
-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
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.
> arp -s 126.96.36.199 00-aa-00-62-c6-09 .... Adds a static entry.
> arp -a .... Displays the arp table.
So, something like arp -s 188.8.131.52 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.
arp -s 184.108.40.206 00-aa-00-62-c6-09
I'm on Windows 7 and am trying to assign a static arp entry for my default gateway using the command:
arp -s 172.24.7.254 00-05-01-f9-28-00 172.24.1.20
But I get the following error:
The ARP entry addition failed: Access is denied.
When I don't mention my ip-address at the end, the static ip gets assigned for the virtual interface created automatically for virtualbox. I'm using an elevated prompt. I'll be grateful for suggestions. Thanks.
Here is what I found and it works great
arp -s : access denied. On the default gateway
Here is what I used :
netsh interface ip delete neighbors "Network card name here" "Gateway.IP.goes.here"
netsh interface ip add neighbors "Network card name here" "Gateway.IP.goes.here" "MAC-address-of-gateway-with-dash-here"
To set arp static in windows 7 64bit you must use netsh comand as follow
enter this command
netsh interface ipv4 add neighbors "Local Area Connection" inetaddr MAC
netsh interface ipv4 add neighbors "Local Area Connection" 192.168.0.1 00-24-01-d2-3a-bd
(If you are using a wireless rather than a LAN cable connection, use "Wireless Network Connection" instead.)
To modify routing info, you need to be an administrator.
Find the Command Prompt in your start menu, right click on it and choose "Run as administrator"