arp-setup.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. # file: arp-setup.sh
  3. # ====================================================================
  4. # environment;
  5. # --------------------------------------------------------------------
  6. . arp-token.sh
  7. # ====================================================================
  8. # disable loopback/WAN interfaces;
  9. # --------------------------------------------------------------------
  10. ifconfig lo down
  11. ifconfig ${IF0} down
  12. # ====================================================================
  13. # enable send-to-self feature;
  14. # --------------------------------------------------------------------
  15. echo 1 > /proc/sys/net/ipv4/conf/${IF1}/loop
  16. echo 1 > /proc/sys/net/ipv4/conf/${IF2}/loop
  17. # ====================================================================
  18. # disable arp on each device;
  19. # --------------------------------------------------------------------
  20. ip link set dev ${IF1} arp off
  21. ip link set dev ${IF2} arp off
  22. # ====================================================================
  23. # discard routes;
  24. # --------------------------------------------------------------------
  25. route del -net ${NET1} netmask 255.255.255.0 dev ${IF1}
  26. route del -net ${NET2} netmask 255.255.255.0 dev ${IF2}
  27. # ====================================================================
  28. # update arp neighbor cache;
  29. # --------------------------------------------------------------------
  30. ip neighbor add dev ${IF1} to ${IP2} lladdr ${NIC2} nud permanent
  31. ip neighbor add dev ${IF2} to ${IP1} lladdr ${NIC1} nud permanent
  32. ip neighbor show