Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function get_public_ips($eth = 'eth0') {
- $ipv4 = array_filter(explode(';', preg_replace('/s/', ';', shell_exec("ip -o -4 addr list " . $eth . " | awk '{print $4}' | cut -d/ -f1"))), 'trim');
- $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');
- sort($ipv4);
- sort($ipv6);
- return Array('ipv4' => $ipv4, 'ipv6' => $ipv6);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement