Skip to main content
deleted 78 characters in body
Source Link
nyet
  • 297
  • 2
  • 4

Original oneliner

ip link set arp off dev eth0 ; ip link set arp on dev eth0

Be sure to do it all at once, so you don't break network connectivity before you're able to turn ARP back on.

Alternate (safer) oneliner:

ip neigh flush all [dev <device>]

Interface discovering copy-paste command

interfaces=$(
  arp -n | awk '
    NR == 1 {next}
    {interfaces[$5]+=1}
    END {for (interface in interfaces){print(interface)}}
  '
);
for interface in $interfaces; do
  echo "Clearing ARP cache for $interface";
  sudo ip link set arp off dev $interface;
  sudo ip link set arp on  dev $interface;
done

Note: The semicolons allow you to condense this command into a oneliner, but it looks terrible in a code block on SO.

Example output on Raspbian

pi@raspberrypi:~ $ arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
10.0.0.1                 ether   58:19:f8:0d:57:aa   C                     wlan0
10.0.0.159               ether   88:e9:fe:84:82:c8   C                     wlan0

pi@raspberrypi:~ $ interfaces=$( arp -n | awk ' NR == 1 {next} {interfaces[$5]+=1} END {for (interface in interfaces){print(interface)}} '); for interface in $interfaces; do echo "Clearing ARP cache for $interface"; sudo ip link set arp off dev $interface; sudo ip link set arp on  dev $interface; done
Clearing ARP cache for wlan0

pi@raspberrypi:~ $ arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
10.0.0.159               ether   88:e9:fe:84:82:c8   C                     wlan0

Original oneliner

ip link set arp off dev eth0 ; ip link set arp on dev eth0

Be sure to do it all at once, so you don't break network connectivity before you're able to turn ARP back on.

Alternate (safer) oneliner:

ip neigh flush all [dev <device>]

Interface discovering copy-paste command

interfaces=$(
  arp -n | awk '
    NR == 1 {next}
    {interfaces[$5]+=1}
    END {for (interface in interfaces){print(interface)}}
  '
);
for interface in $interfaces; do
  echo "Clearing ARP cache for $interface";
  sudo ip link set arp off dev $interface;
  sudo ip link set arp on  dev $interface;
done

Note: The semicolons allow you to condense this command into a oneliner, but it looks terrible in a code block on SO.

Example output on Raspbian

pi@raspberrypi:~ $ arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
10.0.0.1                 ether   58:19:f8:0d:57:aa   C                     wlan0
10.0.0.159               ether   88:e9:fe:84:82:c8   C                     wlan0

pi@raspberrypi:~ $ interfaces=$( arp -n | awk ' NR == 1 {next} {interfaces[$5]+=1} END {for (interface in interfaces){print(interface)}} '); for interface in $interfaces; do echo "Clearing ARP cache for $interface"; sudo ip link set arp off dev $interface; sudo ip link set arp on  dev $interface; done
Clearing ARP cache for wlan0

pi@raspberrypi:~ $ arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
10.0.0.159               ether   88:e9:fe:84:82:c8   C                     wlan0

Original oneliner

ip link set arp off dev eth0 ; ip link set arp on dev eth0

Be sure to do it all at once, so you don't break network connectivity before you're able to turn ARP back on.

Interface discovering copy-paste command

interfaces=$(
  arp -n | awk '
    NR == 1 {next}
    {interfaces[$5]+=1}
    END {for (interface in interfaces){print(interface)}}
  '
);
for interface in $interfaces; do
  echo "Clearing ARP cache for $interface";
  sudo ip link set arp off dev $interface;
  sudo ip link set arp on  dev $interface;
done

Note: The semicolons allow you to condense this command into a oneliner, but it looks terrible in a code block on SO.

Example output on Raspbian

pi@raspberrypi:~ $ arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
10.0.0.1                 ether   58:19:f8:0d:57:aa   C                     wlan0
10.0.0.159               ether   88:e9:fe:84:82:c8   C                     wlan0

pi@raspberrypi:~ $ interfaces=$( arp -n | awk ' NR == 1 {next} {interfaces[$5]+=1} END {for (interface in interfaces){print(interface)}} '); for interface in $interfaces; do echo "Clearing ARP cache for $interface"; sudo ip link set arp off dev $interface; sudo ip link set arp on  dev $interface; done
Clearing ARP cache for wlan0

pi@raspberrypi:~ $ arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
10.0.0.159               ether   88:e9:fe:84:82:c8   C                     wlan0
added 76 characters in body
Source Link
nyet
  • 297
  • 2
  • 4

Original oneliner

ip link set arp off dev eth0 ; ip link set arp on dev eth0

Be sure to do it all at once, so you don't break network connectivity before you're able to turn ARP back on.

Alternate (safer) oneliner:

ip neigh flush all [dev <device>]

Interface discovering copy-paste command

interfaces=$(
  arp -n | awk '
    NR == 1 {next}
    {interfaces[$5]+=1}
    END {for (interface in interfaces){print(interface)}}
  '
);
for interface in $interfaces; do
  echo "Clearing ARP cache for $interface";
  sudo ip link set arp off dev $interface;
  sudo ip link set arp on  dev $interface;
done

Note: The semicolons allow you to condense this command into a oneliner, but it looks terrible in a code block on SO.

Example output on Raspbian

pi@raspberrypi:~ $ arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
10.0.0.1                 ether   58:19:f8:0d:57:aa   C                     wlan0
10.0.0.159               ether   88:e9:fe:84:82:c8   C                     wlan0

pi@raspberrypi:~ $ interfaces=$( arp -n | awk ' NR == 1 {next} {interfaces[$5]+=1} END {for (interface in interfaces){print(interface)}} '); for interface in $interfaces; do echo "Clearing ARP cache for $interface"; sudo ip link set arp off dev $interface; sudo ip link set arp on  dev $interface; done
Clearing ARP cache for wlan0

pi@raspberrypi:~ $ arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
10.0.0.159               ether   88:e9:fe:84:82:c8   C                     wlan0

Original oneliner

ip link set arp off dev eth0 ; ip link set arp on dev eth0

Be sure to do it all at once, so you don't break network connectivity before you're able to turn ARP back on.

Interface discovering copy-paste command

interfaces=$(
  arp -n | awk '
    NR == 1 {next}
    {interfaces[$5]+=1}
    END {for (interface in interfaces){print(interface)}}
  '
);
for interface in $interfaces; do
  echo "Clearing ARP cache for $interface";
  sudo ip link set arp off dev $interface;
  sudo ip link set arp on  dev $interface;
done

Note: The semicolons allow you to condense this command into a oneliner, but it looks terrible in a code block on SO.

Example output on Raspbian

pi@raspberrypi:~ $ arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
10.0.0.1                 ether   58:19:f8:0d:57:aa   C                     wlan0
10.0.0.159               ether   88:e9:fe:84:82:c8   C                     wlan0

pi@raspberrypi:~ $ interfaces=$( arp -n | awk ' NR == 1 {next} {interfaces[$5]+=1} END {for (interface in interfaces){print(interface)}} '); for interface in $interfaces; do echo "Clearing ARP cache for $interface"; sudo ip link set arp off dev $interface; sudo ip link set arp on  dev $interface; done
Clearing ARP cache for wlan0

pi@raspberrypi:~ $ arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
10.0.0.159               ether   88:e9:fe:84:82:c8   C                     wlan0

Original oneliner

ip link set arp off dev eth0 ; ip link set arp on dev eth0

Be sure to do it all at once, so you don't break network connectivity before you're able to turn ARP back on.

Alternate (safer) oneliner:

ip neigh flush all [dev <device>]

Interface discovering copy-paste command

interfaces=$(
  arp -n | awk '
    NR == 1 {next}
    {interfaces[$5]+=1}
    END {for (interface in interfaces){print(interface)}}
  '
);
for interface in $interfaces; do
  echo "Clearing ARP cache for $interface";
  sudo ip link set arp off dev $interface;
  sudo ip link set arp on  dev $interface;
done

Note: The semicolons allow you to condense this command into a oneliner, but it looks terrible in a code block on SO.

Example output on Raspbian

pi@raspberrypi:~ $ arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
10.0.0.1                 ether   58:19:f8:0d:57:aa   C                     wlan0
10.0.0.159               ether   88:e9:fe:84:82:c8   C                     wlan0

pi@raspberrypi:~ $ interfaces=$( arp -n | awk ' NR == 1 {next} {interfaces[$5]+=1} END {for (interface in interfaces){print(interface)}} '); for interface in $interfaces; do echo "Clearing ARP cache for $interface"; sudo ip link set arp off dev $interface; sudo ip link set arp on  dev $interface; done
Clearing ARP cache for wlan0

pi@raspberrypi:~ $ arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
10.0.0.159               ether   88:e9:fe:84:82:c8   C                     wlan0
Added Interface discovering copy-paste command
Source Link
Bruno Bronosky
  • 5.1k
  • 2
  • 30
  • 27

Original oneliner

ip link set arp off dev eth0 ; ip link set arp on dev eth0

Be sure to do it all at once, so you don't break network connectivity before you're able to turn ARP back on.

Interface discovering copy-paste command

interfaces=$(
  arp -n | awk '
    NR == 1 {next}
    {interfaces[$5]+=1}
    END {for (interface in interfaces){print(interface)}}
  '
);
for interface in $interfaces; do
  echo "Clearing ARP cache for $interface";
  sudo ip link set arp off dev $interface;
  sudo ip link set arp on  dev $interface;
done

Note: The semicolons allow you to condense this command into a oneliner, but it looks terrible in a code block on SO.

Example output on Raspbian

pi@raspberrypi:~ $ arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
10.0.0.1                 ether   58:19:f8:0d:57:aa   C                     wlan0
10.0.0.159               ether   88:e9:fe:84:82:c8   C                     wlan0

pi@raspberrypi:~ $ interfaces=$( arp -n | awk ' NR == 1 {next} {interfaces[$5]+=1} END {for (interface in interfaces){print(interface)}} '); for interface in $interfaces; do echo "Clearing ARP cache for $interface"; sudo ip link set arp off dev $interface; sudo ip link set arp on  dev $interface; done
Clearing ARP cache for wlan0

pi@raspberrypi:~ $ arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
10.0.0.159               ether   88:e9:fe:84:82:c8   C                     wlan0
ip link set arp off dev eth0 ; ip link set arp on dev eth0

Be sure to do it all at once, so you don't break network connectivity before you're able to turn ARP back on.

Original oneliner

ip link set arp off dev eth0 ; ip link set arp on dev eth0

Be sure to do it all at once, so you don't break network connectivity before you're able to turn ARP back on.

Interface discovering copy-paste command

interfaces=$(
  arp -n | awk '
    NR == 1 {next}
    {interfaces[$5]+=1}
    END {for (interface in interfaces){print(interface)}}
  '
);
for interface in $interfaces; do
  echo "Clearing ARP cache for $interface";
  sudo ip link set arp off dev $interface;
  sudo ip link set arp on  dev $interface;
done

Note: The semicolons allow you to condense this command into a oneliner, but it looks terrible in a code block on SO.

Example output on Raspbian

pi@raspberrypi:~ $ arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
10.0.0.1                 ether   58:19:f8:0d:57:aa   C                     wlan0
10.0.0.159               ether   88:e9:fe:84:82:c8   C                     wlan0

pi@raspberrypi:~ $ interfaces=$( arp -n | awk ' NR == 1 {next} {interfaces[$5]+=1} END {for (interface in interfaces){print(interface)}} '); for interface in $interfaces; do echo "Clearing ARP cache for $interface"; sudo ip link set arp off dev $interface; sudo ip link set arp on  dev $interface; done
Clearing ARP cache for wlan0

pi@raspberrypi:~ $ arp -n
Address                  HWtype  HWaddress           Flags Mask            Iface
10.0.0.159               ether   88:e9:fe:84:82:c8   C                     wlan0
Prevent poor saps (like me) from accidentally disabling ARP and breaking their SSH connection, and with no way to get back in.
Source Link
Loading
Source Link
nyet
  • 297
  • 2
  • 4
Loading