Bhuvan Kumar
Bhuvan Kumar

Reputation: 564

Restore arp cache in linux

I accidentally delete HWaddress using below command

arp -d 200.9.12.50

if i run the arp -n 200.9.12.50 shows incomplete.

Address                  HWtype  HWaddress           Flags Mask            Iface
200.9.12.50                       (incomplete)                              eth0

I know the exact HWaddress, tried to add manually using below command. I am not able to ping (Destination Host Unreachable), If i reboot the arp will be again set to incomplete. Please help me the restore the arp with HWaddress.

arp -s 200.9.12.50 00:0b:ab:7d:09:4a temp

Upvotes: 2

Views: 856

Answers (1)

Rafael
Rafael

Reputation: 7746

The linux kernel sets the completed arp flag only when the neighbor unreachability detection (nud) state is set permanent (not temporary) or "valid" (arp.c#L1077-L1085).

#define NUD_VALID   (NUD_PERMANENT|NUD_NOARP|NUD_REACHABLE|NUD_PROBE|NUD_STALE|NUD_DELAY)

net/neighbour.h#L38


Looking at net-tools arp.c, this is set in arp_set(). (See net-tools for official source.) If the temp arg is supplied, the permanent flag is disabled which might explain "If i reboot the arp will be again set to incomplete."


Try removing the entry and resetting it without temp:

# arp -i eth0 -d 200.9.12.50
# arp -Ds 200.9.12.50 eth0

(I use iproute2 instead of net-tools; forgive me if any of this information is incorrect.)

Upvotes: 2

Related Questions