Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. function get_public_ips($eth = 'eth0') {
  2. $ipv4 = array_filter(explode(';', preg_replace('/s/', ';', shell_exec("ip -o -4 addr list " . $eth . " | awk '{print $4}' | cut -d/ -f1"))), 'trim');
  3. $ipv6 = array_filter(explode(';', preg_replace(Array('/([a-z0-9:]+).*/', '/s/'), Array('$1', ';'), shell_exec("ifconfig " . $eth . " | grep -Ev ':Link' | awk '/inet6/{print $3}'"))), 'trim');
  4. sort($ipv4);
  5. sort($ipv6);
  6. return Array('ipv4' => $ipv4, 'ipv6' => $ipv6);
  7. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement