arp-clear.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/bash
  2. # file: arp-clear.sh
  3. # ====================================================================
  4. # environment
  5. # --------------------------------------------------------------------
  6. . arp-token.sh
  7. # ====================================================================
  8. # clear arp cache;
  9. # --------------------------------------------------------------------
  10. ip neighbor delete dev ${IF1} to ${IP2} lladdr ${NIC2}
  11. ip neighbor delete dev ${IF2} to ${IP1} lladdr ${NIC1}
  12. ip neighbor show
  13. # ====================================================================
  14. # clear route cache;
  15. # --------------------------------------------------------------------
  16. # ip route add dev ${IF1} to ${IP2} lladdr ${NIC2} table default
  17. # ip route add dev ${IF2} to ${IP1} lladdr ${NIC1} table default
  18. # ip route show
  19. # ====================================================================
  20. # restore route;
  21. # --------------------------------------------------------------------
  22. route add -net ${NET1} netmask 255.255.255.0 dev ${IF1}
  23. route add -net ${NET2} netmask 255.255.255.0 dev ${IF2}
  24. # ====================================================================
  25. # enable arp;
  26. # --------------------------------------------------------------------
  27. ip link set dev ${IF1} arp on
  28. ip link set dev ${IF2} arp on
  29. # ====================================================================
  30. # disable send-to-self feature;
  31. # --------------------------------------------------------------------
  32. echo 0 > /proc/sys/net/ipv4/conf/${IF1}/loop
  33. echo 0 > /proc/sys/net/ipv4/conf/${IF2}/loop
  34. # ====================================================================
  35. # enable WAN connection;
  36. # --------------------------------------------------------------------
  37. ifconfig ${IF0} up
  38. ifconfig lo up