How can I add an active arp entry on Win 7

0

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.

Kevin Gale

Posted 2012-02-17T17:24:22.933

Reputation: 101

Answers

2

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.

RedGrittyBrick

Posted 2012-02-17T17:24:22.933

Reputation: 70 632

Is it possible to disable arp feature completely after setting a static arp entry on Windows? You can do this in Linux. ip link set dev eth0 arp off or ifconfig eth0 -arp. I don't want my windows device to reply to other device's ARP requests because of some reasons. I will just add the gateway's MAC entry manually. So that my internet connection will work. – Sourav Ghosh – 2018-10-29T09:32:50.607

@SouravGhosh: Please use the "Ask Question" link to ask new questions, you can always include a link to this question in your new question if you think it will help people understand your new question. – RedGrittyBrick – 2018-10-29T09:48:23.813

@RedGrittyBrick I have already asked the question more than 1 year ago. https://superuser.com/questions/1183548/ I just commented here to see if any windows experts has an answer. :)

– Sourav Ghosh – 2018-10-29T11:29:48.353

I'm aware of arp. I'll have to test the reboot part, but it specifically says it adds a static entry that is permanent in the help text you show. – Kevin Gale – 2012-02-17T17:59:39.627

It does appear they do go away on a reboot. That still doesn't really answer my question. Why isn't there any way to create a dynamic/active entry that goes away on it's own? Why does the netsh command have store=active option if it's not going to use it? – Kevin Gale – 2012-02-17T18:08:34.250

I up-voted but didn't accept. Knowing the static address will disappear at reboot is helpful since worst case I can use a static and know it will go away eventually. Also I went back to my code and changed the type to static. Now the SetIpNetEntry api works. I still don't understand why it doesn't work for dynamic. Something changed between XP and Win7 and it doesn't even generate a error just a false success. – Kevin Gale – 2012-02-17T18:35:00.583