SHARE
TWEET

List null routed IPs

MartyniP Apr 23rd, 2011 176 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $blackhole = array();
  4.  
  5. $i = 0;
  6.  
  7. exec('ip route list', $exec);
  8. foreach ($exec as $k => $v) {
  9. $pos = strpos($v, 'blackhole');
  10.  
  11. // Note our use of ===.  Simply == would not work as expected
  12. // because the position of 'a' was the 0th (first) character.
  13. if ($pos === false) {
  14.  
  15. } else {
  16.  
  17. $var = explode("blackhole ", $v);
  18. $blackhole[$var[1]] = $var[1];
  19. $i++;
  20. }
  21. }
  22.  
  23. echo $i." IP's blocked
  24. ";
  25. ?>
RAW Paste Data
Top