This shows you the differences between two versions of the page.
linux:network_arp [2024/08/19 10:34] manu created |
linux:network_arp [2024/08/20 00:22] (current) manu |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Linux ARP table ====== | ====== Linux ARP table ====== | ||
+ | |||
+ | https://stackoverflow.com/questions/15372011/configuring-arp-age-timeout | ||
+ | |||
+ | Files related to ARP cache | ||
+ | <cli prompt='$'> | ||
+ | /proc/sys/net/ipv4/neigh/default/gc_interval | ||
+ | /proc/sys/net/ipv4/neigh/default/gc_stale_time | ||
+ | /proc/sys/net/ipv4/route/gc_interval | ||
+ | /proc/sys/net/ipv4/route/gc_timeout | ||
+ | </cli> | ||
+ | |||
+ | gc_timeout seconds | ||
+ | gc_stale_time seconds | ||
+ | | ||
+ | There are subtle differences between an neighbor cache entry actually falling out of the cache entirely or just being marked as stale/invalid. At some point between base_reachable_time/2 and 3*base_reachable_time/2, the entry will still be in the cache, but it will be marked with a state of STALE. You should be able to view the state with "ip -s neighbor show", | ||
+ | <cli prompt='$'> | ||
+ | pherricoxide@midigaurd:~$ ip -s neighbor list | ||
+ | 192.168.42.1 dev eth0 lladdr 00:25:90:7d:7e:cd ref 2 used 184/184/139 probes 4 STALE | ||
+ | 192.168.10.2 dev eth0 lladdr 00:1c:23:cf:0b:6a ref 3 used 33/28/0 probes 1 REACHABLE | ||
+ | 192.168.10.1 dev eth0 lladdr 00:17:c5:d8:90:a4 ref 219 used 275/4/121 probes 1 REACHABLE | ||
+ | </cli> | ||
+ | |||
+ | To mark entries as invalid, but not remove them from the cache | ||
+ | <cli prompt='$'> | ||
+ | $ ip -s -s neigh flush all | ||
+ | </cli> | ||
+ | |||
+ | To delete a particular entry | ||
+ | <cli prompt='$'> | ||
+ | $ arp -d <ip_address> | ||
+ | </cli> | ||
+ | |||
+ | |||
+ | <cli prompt='$'> | ||
+ | $ ip link set arp off dev eth0; ip link set arp on dev eth0 | ||
+ | </cli> | ||
+ | |||
+ | The simplest way to completely clean the arp cache is to bring the interface down and then up again. | ||
+ | |||
+ | Else you can also change the cache timeout | ||
+ | <cli prompt='$'> | ||
+ | $ echo 30 > /proc/sys/net/ipv4/neigh/default/gc_stale_time | ||
+ | $ echo 175 > /proc/sys/net/ipv4/route/gc_timeout | ||
+ | $ echo 20000 > /proc/sys/net/ipv4/neigh/default/base_reachable_time_ms | ||
+ | $ echo 30 > /proc/sys/net/ipv4/route/gc_interval | ||
+ | </cli> | ||