You can add the user your webserver runs as (usually, www or www-data) to /etc/sudoers
. Then you should be able to access the ifconfig command via a system call. Obviously there is a security impact here. You should restrict the access to the ifconfig command if you take that route.
$out = system("sudo ifconfig ...");